also need to close the stream to get it to dump to disk correctly