May be include a comment to explain why this check is here? Otherwise the reader will be puzzled. 
Another thing: Here, we are ignoring null students. Can this mask other serious errors?