I have to wonder if you aren't running in to a buffering problem in that perl may not have written EOF yet, so the OS doesn't know where the file ends. You end up reading garbage until you happen upon an EOF that is residing on the hard drive. I think that you should try explicitly
close your file. At worst, you will see the exact same behaviour. Also of note: if it is a buffering problem, you could have larger issues in that actual data may not get to the file.
thor