in reply to
Compare two txt files and print the difference between the two files.
The code you presented in the OP worked fine for me. I assume the problem you had understanding the output was due to the differences in whitespace at the ends of the lines in your sample text files. The whitespace made some of the lines appear to be different. Once I removed the extra whitespace here is the output which makes sense to me:
--- a_file.txt Fri Feb 1 13:30:39 2013
+++ b_file.txt Fri Feb 1 13:30:55 2013
@@ -1,6 +1,4 @@