Add feof and ferror check.