Ranged for

`for (Iter i = c.begin(); i != c.end(); ++i)` is long, noisy,
and the extra capabilities of iterators over a simple foreach
are mostly not needed.

`make check` and `make -C testsuite-real` are happy with
the changes, still this could use a combover from someone
with OCD.  or better, a run of the acceptance tests.

@k0da, @kobliha
well it preserves semantics of the old code (`while (... && !ret)`, but i agree.  should i swap the two lines?