Add xml declaration when rewriting config.xml

Xml declaration and encoding get lost when rewriting config.xml in switch method. Adding these parameters should fix it.