You should check /help /did wink
'did -r' Clears all text from the ID, not just that line.
'did -o' Overwrites the specified line.

This script should be using '/var' and not '/set'

Code:
on *:dialog:MainMenu:init:*: {
  if ($read(loaded.txt) != $null) {
    var %countloaded = 1
    while ($read(loaded.txt,%countloaded)) {
      var %botname = $v1
      if ($readini(bots.ini,%botname,connected) == connected) { did -a MainMenu 10 %botname (C) }
      else { did -a MainMenu 10 %botname }
      inc %countloaded
    }
  }
}