Fixed generator.next() on Python 3.

Python 3 uses next(generator) instead of generator.next().