changed check to feof(stream)