Why are you using numStudents? You should be using studentNames.size().
One reason i could be out of range is that when you remove a student, you don't decrement numStudents. Since you don't exit the loop when you find a match, so i will index past the new end of the now shorter vector. This is why you should be using studentNames.size() which is automatically decremented when you delete a student. Why do duplicate housekeeping?