fix bug where entire buffer was not flushed to disk before moving files in stream