Hi,
In a traditional mainframe COBOL environment, you can have a definition with a CCC character in the first (extra) byte of your record.
Then you write:
MOVE 'C' TO CCC.
WRITE FOOTER-LINE AFTER POSITIONING CCC.
If you count the lines on each page you write and if you know how many lines fit on one page, you just write your last line after XX lines, where XX is the last line of your page minus the curent line + 1.
Regards,
Crox