String input and output ports do not need to be explicitly closed. The file-position procedure works for string ports in position-setting mode.
|out : output-port?|
|reset? : any/c = #f|
|start-pos : exact-nonnegative-integer? = 0|
|end-pos : exact-nonnegative-integer? = #f|
If reset? is true, then all bytes are removed from the port, and the port’s position is reset to 0; if reset? is #f, then all bytes remain in the port for further accumulation (so they are returned for later calls to get-output-bytes or get-output-string), and the port’s position is unchanged.
The start-pos and end-pos arguments specify the range of bytes in the port to return; supplying start-pos and end-pos is the same as using subbytes on the result of get-output-bytes, but supplying them to get-output-bytes can avoid an allocation. The end-pos argument can be #f, which corresponds to not passing a second argument to subbytes.
|> (define i (open-input-string "hello world"))|
|> (define o (open-output-string))|
|> (write (read i) o)|
|> (get-output-string o)|