ensure that the XML file is always closed when importing from XML