in reply to sending an email to a perl script
I don't think it has anything to do with buffering. I would say that the code is failing to open the file, but it doesn't tell you why, since the code doesn't print $! in the event of an error. (I don't know if you are paraphrasing the code, and omitting the error check).
Another possibility is that something in the while is calling exit, or dying. Again, without seeing the code, it's difficult to know. Can you strip the program down to a bare minimum, for instance, the while loop just counts the number of lines, and print that to the logfile.
A final possibility is that you are opening the output file for create, not append. Maybe the subsequent run trashes the file each time.
• another intruder with the mooring in the heart of the Perl