Flushing output stream in copy2stream method