Replace foo.next() with next(foo)

This patch uses the newer syntax for stepping over an iterable,
with an eye toward Python 3 compatability.

Change-Id: I9763596c0230f807557d0f2bf33d00124937b17c