in reply to Redirecting output

You might want to check if the open statements are sometimes failing (for whatever reason - you never know...). In that case, printing $! might give you some clue.