I figured it out.
You have to replace actual linefeeds with \\n in the AppleScript.
\\n
For more information, see the wiki Searching the Forum for Answers section.