A little more information would make it easier to offer a
suggestion. Could you supply a few lines of sample output,
(disguised if necessary; layout and type of content are more
important than actual values, unless some constant can be
used to discriminate between types of line)?