added finally to close file