rework the output so that a bogus trailing LF is not written