In Bazzy's example, you read from the file, then exit if you are at the end. In the first example, you read from the file, and even if it failed due to EOF conditions, it tries to print some data out. In the case of a failed read, the variables remain unchanged and you get a duplicate line of output.