i think u may specify -1 as a condition in a while loop .. because the end of file represents -1 .. where ur while loop gets terminated