2018-03-21 9:03 GMT+08:00 C K Kashyap <ckkashyap@gmail.com>:
Thanks Adam,

I was wondering then, what would be a better way to do this - 
(with-output-to-file "output.txt"
  (lambda ()
    (display
     (call-with-input-process
      program
      (lambda (port)
(read-line port #f))))))

If I understand it right, this requires an extra read and write. If Gambit lets the port be overridden by the surrounding with-output-to-file, perhaps the whole thing could be achieved without the extra read and write. Hence my question was more about whether there is a problem with this approach that I am not able to see.

If you're trying to achieve "/bin/sh -c \"program > output.txt\"", then first that's not what you're doing here, and second, you would benefit of using read/write-subu8vector for the forwarding as it's faster. Or you could ask the OS to do it using |shell-command|.

You need to clarify your problem specification and code example for anyone to be able to give you more guidance.