fix flushing output