How about we “flip the script” here – show us the script that you have, and the scripters here may be able to diagnose the fault.
If this is a commercially sensitive script and can’t be posted here, I’ll completely understand. Just be aware though that many scripters will feel the same way about providing their own scripts to you for the purpose of beta-testing your product.
I’m aware of one script that Rorohiko may do what you’re after, it’s called textstitch: https://www.rorohiko.com/wordpress/indesign-downloads/textstitch/