fixed bug in the output routine related to removing new lines to compensate for added lines