Hi,
I think your error is the "do (r.next()) {" call. your opening "if" stmt already opened the first row in the recordset... I would assume no more rows can be found, or because you have an "r.next()" stmt on the do and while, then each itteration is progressing 2...