Closing stream after copy operation