Added toStream() method.