in reply to XML file creation based on file existence

in your code:

Hopes those comments will help you out.