Fixing an infinite loop when there is no newline at the end of the file.