code: def write(self, filename=None, ncol=ncol, format=format):
          
          with open(self.filename(filename, ext='ndx'), 'w') as ndx:
              for name in self:
                  atomnumbers = self._getarray(name)  # allows overriding
                  ndx.write('[ {0!s} ]\n'.format(name))
                  for k in range(0, len(atomnumbers), ncol):
                      line = atomnumbers[k:k+ncol].astype(int)   # nice formatting in ncol-blocks
                      n = len(line)
                      ndx.write((" ".join(n*[format])+'\n') % tuple(line))
                  ndx.write('\n')
docs: Write index file to *filename* (or overwrite the file that the index was read from)