put pointer assignment after test

I put the line I had moved into the loop the wrong side of the test
conditional.