in reply to process multiline text and print in desired format

You only ever do anything (print the line) for the "header" line of each of your blocks. Two approaches that come to mind:

The cake is a lie.
The cake is a lie.
The cake is a lie.