Changed .next to next()

Fixed bug preventing py3 compatibility - tested in both py2 and py3 environments.