while(!feof(fp)){

FAQ > Why it's bad to use feof() to control a loop - Cprogramming.com

Bye, Andreas