Use fixed `write_file` instead of re-implementing