I'm not sure I understand why this is necessary. Can't you just `count('\n')` in `next()`?