Alrighty, another question

"Additional information: StartIndex cannot be less than zero."

thats what happens when i run out of the string im searching for, it stops debugging, etc, is there a way i can make it so it just exits the loop when that happens?