Did minor fix to flush the output buffer when writing.