Delete dead code
Simplify error handling
Avoid forcing the iterator

The current processing works well in streaming fashion.
Fuse two loops over input to resemble pipeline

This fusion simplifies the code - the current code is in some sense just
an eta-expansion of the one after simplification.
Unify code
Reorder code
Inline more code
Use string interpolation