Writes the message to a stream.