It fails when the typeat goes over two lines, as in:
      typat      1  1  1  1  1  1  1  1  4  2  2  2  2  2  2  2  3  3  3  3
                   3  3  3  3  3  3  3  3  3  3  3  3  3  3  3  3  3  3  3It fails when the typeat goes over two lines, as in:
      typat      1  1  1  1  1  1  1  1  4  2  2  2  2  2  2  2  3  3  3  3
                   3  3  3  3  3  3  3  3  3  3  3  3  3  3  3  3  3  3  3