closing flushes the stream so the fflush should be redundant