transform a stream into a quoted string