May be this function can help:
def checkChange(FileName, oldContent):
fSrc = open(FileName, 'r')
actualContent = fSrc.read()
fSrc.close()
if actualContent != oldContent:
print(1)
return actualContent
solved Python Check txt variable loop [closed]