Demonstration of the difference between approaches https://superuser.com/a/663694/442895 and https://superuser.com/a/496421/442895 :
The test files were generated with:
$ </dev/random base64 | tr -s \\n \ | head -c 1000000 > file1.txt
For file2.txt I copied file1.txt and manually removed the 800th and the 80th characters.