copy stream before delting and yielding on flush