Save a stream to a file