fix file output buffer issue