At the end of both functions, the file opened locally is closed automatically when the corresponding
stream goes out of scope. The destructors of the classes ifstream and ofstream take care of
closing the file if it is still open at destruction time.
Instead of copying the file contents character by character, you could also output the whole
contents in one statement by passing a pointer to the stream buffer of the file as an argument to
operator