This solved my problems.
set myFiles to (choose file with multiple selections allowed)
display dialog "Text to replace" default answer ""
set textToReplace to text returned of result
display dialog "Text to insert" default answer ""
set textToInsert to text returned of result
repeat with aFile in myFiles
set myData to do shell script "cat " & quoted form of (aFile's POSIX path)
set newData to do shell script "echo " & quoted form of myData & " | sed 's/" & textToReplace & "/" & textToInsert & "/g' > " & quoted form of (aFile's POSIX path)
end repeat