did you try select on LOG before forcing autoflush ($|++;)?
UPDATE : Forget this post, I took too much time to submit this one. And the question was answered during the looooong time I took to check my answer. :-(
Re: open, sleep, & print together cause an error
Replies are listed 'Best First'.