Split the write file method and added a method to return the xml as a string.