Fixes EOF newline handling for text file