implemented copyto, to the stream with a buffer.