make write_restart function