while(!feof(fp)) - do not use feof to control loop, read FAQ http://faq.cprogramming.com/cgi-bin/...&id=1043284351