The sleep should not be necessary. But at the same time, you should not have to open and close the same file repeatedly like that. Once you have a FILE* stream open, you can jump around in the file...