Great question — answering as the UphillTech team:
My problem was solved when I re-installed python on my pc due to some other problem. Now, when I run the code, it works like magic! All the chunks are being saved now regardless of whether I save them all in one go or in batches. EDIT: The problem was actually due to a conflict in the installed libraries. It gets resolved when you use a virtual environment, so no need to re-install python.
Full answer by hassaanq: https://stackoverflow.stackexchange.com/a/78774435 (CC BY-SA 4.0).
Need it done for your business? UphillTech.