Correct handling of files with empty last line