class LineOffsetIterator implements Iterator<Integer> {

    private int curr = 0;
    private int idx = 0;
    private final String input;

    private LineOffsetIterator(String input) {
      this.input = input;
    }

    @Override
    public boolean hasNext() {
      return curr != -1;
    }

    @Override
    public Integer next() {<FILL_FUNCTION_BODY>}

    private void advance() {
      for (; idx < input.length(); idx++) {
        char c = input.charAt(idx);
        switch (c) {
          case '\r':
            if (idx + 1 < input.length() && input.charAt(idx + 1) == '\n') {
              idx++;
            }
            // falls through
          case '\n':
            idx++;
            curr = idx;
            return;
          default:
            break;
        }
      }
      curr = -1;
    }

    @Override
    public void remove() {
      throw new UnsupportedOperationException("remove");
    }
  }

      if (curr == -1) {
        throw new NoSuchElementException();
      }
      int result = curr;
      advance();
      return result;
    
<no_super_class>