def METHOD_NAME(filepath, mem_file):
  file_changed = True
  if os.path.exists(filepath):
    with open(filepath, 'r', encoding='utf-8') as f:
      mem_file.seek(0)
      file_changed = f.read() != mem_file.read()
  if file_changed:
    with open(filepath, 'w', encoding='utf-8') as f:
      mem_file.seek(0)
      f.write(mem_file.read())