AppleScript added value inside text Let say I have the following text file : 


  
  DEMO
  TEXT1
  TEXT2
  DEMO
  etc....
  DEMO
  TEXT1
  TEXT2
  DEMO
  etc....
  DEMO
  TEXT1
  TEXT2
  DEMO
  etc....
  


I would like to added some text between the first TEXT1 and TEXT2 (line 2/3)

so the text would be like :


  
  DEMO
  TEXT1 MY TEXT HERE
  TEXT2
  DEMO
  etc....
  DEMO
  TEXT1
  TEXT2
  DEMO
  etc....
  DEMO
  TEXT1
  TEXT2
  DEMO
  etc....
  


I know how I can filter the text to get the value of any text that would be there with the code bellow, but how can I add some text on my text file at this empacement ?

property leftEdge1 : "2. TEXT1"
property rightEdge1 : "3. TEXT2"
set myNewCaseNote to ""
set newFile to (path to desktop folder as text) &amp; "_Note_Backup.txt"
set theSource to read file newFile
set theText to Unicode text
try
    set saveTID to text item delimiters
    set text item delimiters to leftEdge1
    set classValue to text item 2 of theSource
    set text item delimiters to rightEdge1
    set myCaseNote to text item 1 of classValue
    set text item delimiters to saveTID
    myCaseNote
end try
Text processing should be done with shell script. Usually it can be done in one short line:

sed 's;^[^0-9]*2 TEXT1;&amp; MY TEXT HERE;' text_file.txt


Assuming there wasn't some sort of indentation problem above. Based on what it sounds like you meant though, here's another solution:

sed 's;^[^0-9]*2 TEXT1;&amp;\'$'\n'' MY TEXT HERE;' text_file.txt


AppleScript is not the right tool for this job.