When trying to make things work, it helps to include debug messages, such as using the -s switch with the /var command so you can see exactly what is/isnt being filled into the variable, or using an echo to see the contents of the parameters used for writing/reading disk.

It looks like you're using !addcommand to add 1-line aliases to the bot, but then you're writing to a file which is being loaded into remote script. That means either $2- needs to begin with the alias keyword, or you need to specifically write alias to the beginning of each line, which then affects how you search for an existing command to kill it, or else you should load it with -ra into the aliases tab.

When you say it doesn't work, is it just the finding that doesn't work, or the writing, or the executing?