I'm out of ideas, sorry. If the eof()/chomp construct does actually help, then it would probably be best to leave it be it's a clear sign that some other part of the code is broken. Could you maybe post your whole script somewhere (e.g. pastebin.com, pastie.org, your public scratchpad etc.)?