Replace use of EOFError by iteration protocol.