You might want to start checking for the existance of directories as well, depending on the max index you're trying. If the "42" dir doesn't exist, it doesn't make sense to try to get images 1.jpg through 1000.jpg from there either. Not sure if there is a server-independent way of checking this though.
Comment on Re: download JPG series with error-handling