This code works exactly as you want it to when I test it.

By chance, do you have any links to these files in the same directory? I know that sounds odd, but when I create links to any of the files I tested this code with, the contents of the linked file were doubled in the output. (the glob section of the python documentation explains this).

I hope this is of some use, because otherwise your code works perfectly for me....