Hey Chaps, this will probably be an easy one for most of you, but either I don't fully understand it, or I'm getting the syntax wrong.

What I'm trying to do (which has been successful), is create a way to allow users to create their own commands in the bot (This works, and has been tested, see below code), as well as a way for me to completely add commands to the bot using my twitch channel (I've since got a slave machine (Wyse 3030 with Windows 10) to run the bot 24/7). Due to having the bot on another machine, I've been attempting to code a way to be able to add / remove commands remotely without needing to remote onto the machine.

Code
on *:TEXT:!addcommand *:#: {
  if ($nick != eggfriedcheese) { return }
  .msg # ! Adding new command. Please Wait...
  write C:\Users\danie\AppData\Roaming\mIRC\additionalcommands.txt on *:TEXT:! [ $+ [ $2 ] ] [ $+ [ $chr(58) ] ] [ $+ [ $chan ] ] [ $+ [ $chr(58) ] ] [ $+ [ $chr(32) ] ] [ $+ [ $chr(123) ] ] [ $+ [ $chr(32) ] ] .msg # [ $+ [ $chr(32) ] ] [ $+ [ $3- $chr(32) ] ] [ $+ [ $chr(125) ] ]
  .timer 1 2 .msg # ! The bot is reloading the command list, please wait...
  .timer 1 3 /reload -rs C:\Users\danie\AppData\Roaming\mIRC\additionalcommands.txt
  .timer 1 5 .msg # Command List Refreshed. Command ! [ $+ [ $2 ] ]  is now active.
}

on *:TEXT:!addcommandfull *:#: {
  if ($nick != eggfriedcheese) { return }
  .msg # ! Adding new command. Please Wait...
  write C:\Users\danie\AppData\Roaming\mIRC\additionalcommands.txt $2-
  .timer 1 2 .msg # The bot is reloading the command list, please wait...
  .timer 1 3 /reload -rs C:\Users\danie\AppData\Roaming\mIRC\additionalcommands.txt
  .timer 1 5 .msg # Command List Refreshed. Command is now active.
}

on *:TEXT:!removecommand *:#: {
  if ($nick != eggfriedcheese) { return }
  .msg # ! Removing command: ! $+ $$2 $+ . Please Wait...
  $read(C:\Users\danie\AppData\Roaming\mIRC\additionalcommands.txt,w,*[ $+ [ $2 ] ]*)
  .msg # $readn
  write -dl $+ $readn C:\Users\danie\AppData\Roaming\mIRC\additionalcommands.txt
  .timer 1 2 .msg # The bot is reloading the command list, please wait...
  .timer 1 3 /reload -rs C:\Users\danie\AppData\Roaming\mIRC\additionalcommands.txt
  .timer 1 5 .msg # Command List Refreshed. Command: [ $+ [ $chr(32) $2 ] ] has been removed.
}

on *:TEXT:!reload:#: {
  if ($nick != eggfriedcheese) { return }
  .msg # Reloading commands. Please Wait
  /reload -rs C:\Users\danie\AppData\Roaming\mIRC\additionalcommands.txt
  .timer 1 5 .msg # Commands Reloaded Manually.
}


The issue I'm having, is the !removecommand. I'm aiming to find $2 within the file, choose that line, and remove it / write over the line (ideally), stating "; Command $$2 Removed", so I can see when commands have been deleted.

On checking $readn, it comes back with the integer of 0, meaning it's not finding it within the file.

I guess my syntax is wrong, but can someone take a look and correct, or point me in the right direction how to fix it? I've looked at mIRC and the wiki, and I've tried multiple different attempts, all of which have failed.

Thanks
Egg


Twitch Live-Streamer:
Synth Riders
Beat Saber
www.twitch.tv/eggfriedcheese