Code:
on *:text:*:#: {
  if ($1 == ?) {
    var %text = $2- =>
    %text = $read(learnt.txt, w, %text $+ *)
    ;if "this entry*" is found at the beginning of a line,
    if (%text) {
      var %term = $reptok(%text,=>,is,1,32)
      msg $chan hmm, %term
    }
  }
  if ($1 == !append) {
    var %islocation = $findtok($2-,is,1,32)
    if (%islocation) {
      var %text = $2-
      %text = $reptok(%text,is,=>,1,32)
      var %newentry = $gettok(%text,1- $+ %islocation,32)
      var %findentry = $read(learnt.txt,w,%newentry $+ *)
      var %foundentry = $gettok(%findentry,1- $+ %islocation,32)
      if (%newentry == %foundentry) {
        var %append = $gettok(%text,$calc(%islocation +1) $+ -,32)
        write -l $+ $readn learnt.txt %findentry or %append
        msg $chan Appended data.
      }
    }
  }
  if ($1 == !replace) {
    var %islocation = $findtok($2-,is,1,32)
    if (%islocation) {
      var %text = $2-
      %text = $reptok(%text,is,=>,1,32)
      var %newentry = $gettok(%text,1- $+ %islocation,32)
      var %findentry = $read(learnt.txt,w,%newentry $+ *)
      var %foundentry = $gettok(%findentry,1- $+ %islocation,32)
      if (%newentry == %foundentry) {
        var %replace = $gettok(%text,$calc(%islocation +1) $+ -,32)
        write -l $+ $readn learnt.txt %newentry %replace
        msg $chan Replaced entry.
      }
    }
  }
  if ($1 == !learn) {
    var %islocation = $findtok($2-,is,1,32)
    if (%islocation) {
      var %text = $2-
      %text = $reptok(%text,is,=>,1,32)
      var %newentry = $gettok(%text,1- $+ %islocation,32)
      var %findentry = $read(learnt.txt,w,%newentry $+ *)
      var %foundentry = $gettok(%findentry,1- $+ %islocation,32)
      if (%newentry == %foundentry) {
        msg $chan Already have something for that.
      }
      else {
        write learnt.txt %text
        ;write this to a file: this entry => that info
        ;after it's done writing verify that the data did write to the file and if so have it tell you "ok".
        if ($read(learnt.txt,w,%text)) { msg $chan ok }
        else { msg $chan I pooped my pants }
      }
    }
  }
  if ($1 == !delete) {
    var %text = $2- =>
    %text = $read(learnt.txt, w, %text $+ *)
    if (%text) {
      write -dl $+ $readn learnt.txt
      msg $chan Deleted entry.
    }
    else { msg $chan Info does not exist to delete }
  }
}

[13:04:12] <Sporc> !delete variable
[13:04:12] <@Scorpwanna> Deleted entry.
[13:04:19] <Sporc> !delete variable
[13:04:19] <@Scorpwanna> Info does not exist to delete


We don't just write the scripts, we put them to the test! (ScriptBusters)