Fixed the output stream incomplete data by explicitly flushing the OutputStreamWriter