How can I replace some words in my text file by keywords provided in another file using python?
Try i.lower(). 

It might be that document is not a string, but a function at the time in which you call document.replace(t, j)