modified write_file in ARM mode