IMO, changing the order of arguments to write_file makes more sense.