Added write_file helper