This is usually caused by failing to close the file stream after writing.
Simply putting a file in a zip doesn't guarantee smaller file sizes. You must explicitly ask for compression.
This is essential for adding new files to an existing archive without destroying the previous contents. Best Practices for Python Zipping
Using zipfile.ZipFile(b, mode='w') followed by zf.writestr('archive_name.txt', data_bytes) , you can populate archives on the fly.
This creates a new zip file or overwrites an existing one.
Always use with zipfile.ZipFile(...) as zipf: to ensure the file is closed properly, even if errors occur.
