AppleScript: How to write to text file in specific location (signaled by specific character)?
Here's a shell script:

sed -i '' -e ':a' -e 'N' -e '$!ba' -e 's/\n\n/\
Write the new line you wish inserted in your file here\
\
/' ~/Desktop/file.txt


You can wrap this in a ‘do shell script’ if you really want AppleScript, but for an Automator script, you can use a Run Shell Script action and just use the shell script.



Here's an AppleScript wrapper for the script, where the TextToWrite variable and the Target_Filepath variable have been defined elsewhere per your comments:

set addline to "sed -i '' -e ':a' -e 'N' -e '$!ba' -e 's/\\n\\n/\\
" &amp; TextToWrite &amp; "\\
\\
/' \"" &amp; Target_Filepath &amp; "\""
do shell script addline