while (1){
if (fp != NULL) {
if (fgets(buff, sizeof(buff), fp) == NULL) break;
} else {
break;
}
cnt++;
}

これでいいかなぁ