in reply to Printing Line Numbers in output file
What you are describing ... absolutely to a “t” ... is the diff command.
If you cannot simply find a copy of that command (it's built-in to Unix/Linux and readily available also for Win32), there are a variety of Perl packages on search.cpan.org which deal specifically with diff operations in many different forms.
A very closely related technology is called patch.
Search using these keywords and you'll quickly find exactly what you need.