fix for writing the xml file