code: def write_string_to_file(path, string, make_parents=False, backup_suffix=BACKUP_SUFFIX, encoding="utf8"):
    
    with atomic_output_file(path, make_parents=make_parents, backup_suffix=backup_suffix) as tmp_path:
      with codecs.open(tmp_path, "wb", encoding=encoding) as f:
        f.write(string)
docs: Write entire file with given string contents, atomically. Keeps backup by default.