Lseek did not work properly. Always close the file and reopen.