The infinite loop lies here:
while(j < rows)
The loop depends on the value of j being updated and eventually not less than rows. Since j is never changed inside the loop, one of two things happens. Either the loop doesn't start, or if it does, it never stops. There has to be something inside the loop that ...