Hello, I'm a cyber security engineer,
are you using some kind of proxies? I can fix your script to make it try again from the last link without breaking.. (this always happens when the server side closes the connection when receiving a high traffic from a single ip address)