Pleas help..this is driving me crazy

Hi, I've created a script in csh that takes a file and checks it for mispelled words. Im almost done but I need to do two more things but I need help.

First, when displaying an incorrect word to the user, I need to show the line of the input file that contains the word.
Second,if the user gives a replacement word, then I need to actually replace the word in the input file.

heres my code ...........

#!/bin/csh
#script that will spell check a file

set array = (`ispell -l -p $HOME/memory.txt < $1`)

set correct = ""
set incorrect = ""

foreach word ( $array )
  echo $word is mispelled. Press "enter" to keep this spelling, or type a correction
  set correction=$<
  if($correction == "") then
     echo $word >> "$HOME/memory.txt"
  else
     set correct = ( $correct $correction )
     set incorrect = ( $incorrect $word  )
  endif
end

echo "MISPELLED"'-'"CORRECTIONS"
@ counter = 1
foreach $word ( $correct )
  echo $incorrect[$counter]        $correct[$counter]
   @ counter++
end

PLEASE HELP ME!!!