In write_action_file(), reduce the scope of a fd scalar and convert an open call...