Why are there nested loops? The loop only needs to look at one column in each row. The one where the student id is located.
The other columns in the row contain other data about the student.
I suggest that the search loop be rewritten to use a single loop.