def METHOD_NAME(self, filename, text):
    buf = ""
    try:
        with open(filename) as f:
            buf = f.read()
    except FileNotFoundError:
        pass
    if buf != text:
        with open(filename, "w") as f:
            f.write(text)