There's a Python library:
https://archive.org/services/docs/api/internetarchive/
And script:
https://archive.org/services/docs/api/internetarchive/cli.ht...
Which really helps you automate stuff.
https://pypi.org/project/internetarchive/
It turns your script into:
for i in $(seq 1 221)
do
ia download Dungeon_Magazine_$(printf "%03d" $i) --glob='*.pdf'
done
Try 'ia help download' for more information.