ensure stream is flushed