As the other answers state, you are not closing your output file. The proper way of saving XML files using LinqToXML is:
System.Xml.XmlWriterSettings xws = new System.Xml.XmlWriterSettings();
xws.Indent = true;
xws.IndentChars = "\t";
FileStream fsConfig = new FileStream(path, FileMode.Create);
using (System.Xml.XmlWriter xw = System.Xml.XmlWriter.Create(fsConfig, xws))
{
doc.Save(xw);
}
fsConfig.Close();
This releases the file & stream. You can omit the XmlWriterSettings
if not needed.