FWIW, here's another way of editing a TextEdit .rtf document, using an ASObjC-based library rather than TextEdit:
use framework "Foundation"
use framework "AppKit"
on testIt()
-- make URL of file
set aURL to current application's |NSURL|'s fileURLWithPath:"/Users/shane/Documents/ASObjC Explorer for Mavericks/ASObjCExtras_stuff/ASObjCExtras.rtf"
-- get the text as an attributed string, as well as the document attributes
set {theAttrText, docAttrs} to current application's NSAttributedString's alloc()'s initWithURL:aURL documentAttributes:(reference)
-- make the text mutable
set theAttrTextMutable to theAttrText's mutableCopy()
-- add to the text
--theAttrTextMutable's appendAttributedString:(current application's NSAttributedString's alloc()'s initWithString:"=azertyuiop=")
repeat 6 times
theAttrTextMutable's appendAttributedString:theAttrTextMutable
end repeat
-- get length of the text
set theLength to theAttrTextMutable's |length|()
log theLength --> (*925312*)
-- make the font
set theFont to current application's NSFont's fontWithName:"Menlo-Regular" |size|:11.0
-- add the attribute
theAttrTextMutable's addAttribute:(current application's NSFontAttributeName) value:theFont |range|:({0, theLength})
-- convert the attributed string back to RTF data
set theData to theAttrTextMutable's RTFFromRange:({0, theLength}) documentAttributes:docAttrs
-- save the data to a new file
theData's writeToFile:"/Users/shane/Documents/ASObjC Explorer for Mavericks/ASObjCExtras_stuff/ASObjCExtras-2.rtf" atomically:true
end testIt
The final string in this case was 925312 characters, or just under 16000 lines. The script takes less than 0.25 seconds on my Mac. If I apply the styling before the appending, it drops to around 0.02 seconds. (And if I don't, and I keep adding more text, the time increases much more than linearly.) I suspect the fact that I'm running from an SSD helps keep the latter value low.