New question about Var's Replacing?

Is there a way to replace a specific line in a text file?

For Mirc it’s /write -l5 C:\Filepath [text] (exe replace line 5 with [Text] ) (sorry only lang i know semi well

exe for mirc

/rewrite /write -l $+ $?=“line to overwrite” C:\Filepath %var $?= New data

How would you go about doing that in action script for
on (release) {
Increase line 1 by +1 or Replacing that line
}

would prefer to replace a var
so that variable is saved even if they exit the file