adding file closing
refactored and sorted duplication of responses