Code:
while (!feof(fp))
This is a bug - Why it's bad to use feof() to control a loop - Cprogramming.com

... and also this faq: Question 12.2