rewrite for buffered output

Signed-off-by: Stephen Gran <steve@lobefin.net>