total_out isn't what we want till we've flushed the stream.
Less hackiness.