private void writeCommentExtension(OutputStream os) throws IOException
  {
    os.write((int) '!');     // GIF Extension Introducer
    os.write(0xfe);          // Comment Extension Label

    int remainder = theComments.length() % 255;
    int nsubblocks_full = theComments.length() / 255;
    int nsubblocks = nsubblocks_full + (remainder > 0 ? 1 : 0);
    int ibyte = 0;
    for (int isb = 0; isb < nsubblocks; ++isb)
    {
      int size = isb < nsubblocks_full ? 255 : remainder;
      
      os.write(size);
      Put.ascii(theComments.substring(ibyte, ibyte + size), os);
      ibyte += size;
    }

    os.write(0);    // block terminator
  }