               (log/warn ::clj-session-overload msg))))
 
         session-out
-        (PrintWriter-on
+        (writer->fn
           (fn [text]
             (send-msg {::m/op ::m/session-out
                        ::m/session-out text}))
           nil)
 
         session-err
-        (PrintWriter-on
+        (writer->fn
           (fn [text]
             (send-msg {::m/op ::m/session-err
                        ::m/session-err text}))

        s))))


;; taken from clojure/core/server.clj 1.10 alphas

(defn ^java.io.PrintWriter PrintWriter-on
  "implements java.io.PrintWriter given flush-fn, which will be called
  when .flush() is called, with a string built up since the last call to .flush().
  if not nil, close-fn will be called with no arguments when .close is called"

            (InputStreamReader.)
            (LineNumberingPushbackReader.))

        send-msg
        (fn [msg]
          (let [msg (assoc msg
