with-error-output-to-port pasted by rwinkler on Sat May 19 21:21:58 2012

(define port (open-output-file "/tmp/test.txt"))
(with-error-output-to-port port (lambda () (format #t "blabla"))
(close-output-port port)

like this? pasted by certainty on Sat May 19 21:27:38 2012

(call-with-output-file "/tmp/test.txt" 
   (lambda (out) 
     (with-error-output-to-port out (lambda () (display "foobar" (current-error-port)) (newline (current-error-port))))))

correction added by rwinkler on Sat May 19 21:30:24 2012

(with-error-output-to-port port (lambda () (display "blabla" (current-error-port))))