Just playing around with your script. Im basically having 2 issues so far.
1. I'm no shared hosting for this site, and it keeps stopping every 1000 or so pages and i have to click the run button over and over. This is a pain when I have 120,000 pages.
2. This one seems to be creating an invalid sitemap.xml file and its BLANK/WHITE when i view sitemap.xml. Just a note about this, sense im testing i set limit to 90 links and 10 links per xml sitemap to see how the multi xml file feature worked. The sitemap1/2/3 .xml creations work and DO validate fine, its only the main sitemap.xml that is not working properly the others I can see fine in my browser.
Your tool (
https://www.xml-sitemaps.com/validate-xml-sitemap.html) reports this for sitemap.xml
------------------------------------------------------------------------------
XML Validation Results ([ External links are visible to forum administrators only ])
[ External links are visible to forum administrators only ]
Sitemap URL [ External links are visible to forum administrators only ]
Characer Set
Sitemap is valid No
Warnings -
Errors
Incorrect http header content-type