Correctly close file in desctructor