The file pointer won't tell you when the end of file has been reached. The result of fgets() will, and you're missing some semi-colons from the end of your function calls.