The XML file was being generated as UTF-8. By changing the format to ASCII the issue was resolved.
The CreateTextFile function has an optional parameter that to specify the type of file. By setting this value to false (default) the file was generated as ASCII.