To fix the issue, use 'file.file.seek(0)' to return the cursor back to the first line. After reading through, the content of the file, the cursor position is now set to the last line.