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