If I understand the situation correctly, I think it would be easier to work with XmlDocument rather than using a XmlWriter to write the content.
With XmlDocument you can create/modify/delete the content and when needed you can save or load the document to disk.
For more information, have a look at
XmlDocument Class (System.Xml) | Microsoft Docs[
^]