added file close. added step to create file to intermediary file then move into place.