Well, if you really want to change the data inside your script (which I find stupid (sorry)), get the exact line number for each line you want to modify. After, within the script, open the (same) script with file(). It will put each line in an array. Then, with the line number, make the modification in the array. Join the array with "\n" and write that in the (same) script.
NOTE: line number starts from 1 to infinity, but in the array, it's from 0 to infinity, so when you make modifications in the array with the line number, you must do this: [line number] - 1. Example : if you line number is 1, in the array, it will be 0.