You can't append an XML file - you'll have to load the file in memory , modify/add/etc, and then write it to disk.
and then start adding the keepalive stuff.
I would actually go a bit further and not mess around with xml. I'd
create a class that contains everything I need and just serialize and
deserialize it.
Here's an example of adding a new element to the root node:
XDocument doc = XDocument.Load("test.xml");
doc.Root.Add(new XElement("someNode", "some node value"));
doc.Save("test.xml");