Added an output flush after writing to the output stream.