Question: I am using a `XMLWriter` to create a basic XML, the XML file has one element that everything is in, for the sake of explaining it lets say this is just `people` then inside that there needs to be multiple elements inside of it, lets call them `person` then inside of them we have elements called `names`.

So it would look like this

```
<?xml version="1.0" encoding="utf-8"?>
<people>
  <person>
    <name>Name1</name>
  </person>
  <person>
    <name>Name2</name>
  </person>
  <person>
    <name>Name3</name>
  </person>
</people>

```

But when I go to write a new `person` it will just come out like this (its just overwriting it):

```
<?xml version="1.0" encoding="utf-8"?>
<people>
  <person>
    <name>Name5</name>
  </person>
</people>

```

I am using this to write each `person` element...

```
writer.WriteStartElement("person");
writer.WriteElementString(keys[i], values[i]);
writer.WriteEndElement();

```

Any way to stop it overwriting?

Answer: 
If you want to try [LinqToXml](http://msdn.microsoft.com/en-us/library/bb387061.aspx)

```
var xDoc = XDocument.Load(fileName);

var people = xDoc.Element("people");
people.Add(new XElement("person", new XElement("name", "name4")));

xDoc.Save(fileName, SaveOptions.None);

```
The answer provided by L.B is what I would personally use. In regards to the xml writer, I'm not sure if this will work, but it's worth a shot. Try creating the filestream in append mode.

```
Stream xmlFile = new FileStream(@"c:\path",FileMode.Append);
XmlTextWriter xmlWriter = new XmlTextWriter(xmlFile, Encoding.Default);

```