Possible Duplicate: Why doesn't getchar() recognise return as EOF in windows console? .... Reading from text file until EOF repeats last line ...
stackoverflow.com