in reply to Diff 2 files and print output to file
For a Perl solution, searching through Categorized Questions and Answers, it seems the answers to How do I compare the lines in two text file? may be helpful, particularly Algorithm::Diff.