in reply to Closing program when end of files is reached

First off, your program does stop when it reaches the end of the file, that's just your trouble... you have a blank line just before the end of your file.

Perhaps you should check if the line has anything in it and stop parsing?

while (<FILE>) { last unless /^\n$/; do stuff(); }
Enjoy!
--
Casey