Closing file properly