never clears any state flags. Thus, if a stream was not in a good state after closing and reopening it,
you still have to call clear() to get to a good state. This is also the case if you open a different file.
Instead of processing character by character, you could also print the entire contents of the file in
one statement by passing a pointer to the stream buffer of the file as an argument to operator