Are you indexing a site that requires authentication to enter? If so, read
this thread.
If that isn't the problem at all, and I know this probably sounds like a dumb question, but what is in line 667 in your code? Some of us have customized our code so that line 667 for us isn't necessarily the same line of code for you.