Fix two minor bugs found by /analyze
/analyze pointed out that the loop range-check used the comma operator
when && was probably intended. The bug was harmless, but confusing, so
I fixed it.
/analyze also pointed out that the code was checking data read by a
function and then checking whether the read succeeded. Reversing the
order of the checks has no effect except to get rid of the undefined