TextWrangler: Duplicate lines

The last three process commands work fine when I run then as single command in a script. However, in this script I get error 1700 (“Missing command parameter”) for every one of them. How come?

tell application "TextWrangler"
	tell front text window
		-- Conversion from TMX to tab-del
		-- Insert tab characters between source and target segments
		replace "<\\/seg.*?seg>" using "	" options {search mode:grep, starting at top:true}
		-- Remove segment ending markup
		replace "</seg></tuv></tu>" using "" options {starting at top:true}
		-- Remove closing body markup
		replace "</body>" using "" options {starting at top:true}
		-- Remove closing TMX markup
		replace "</tmx>" using "" options {starting at top:true}
		-- Remove any TMX header
		replace "<\\?[\\w\\W]*<body>\\r" using "" options {search mode:grep, starting at top:true}
		-- Remove segment start markup
		replace "<tu.*?seg>" using "" options {search mode:grep, starting at top:true}
		-- Start cleaning up the tab-del
		-- Remove numbers
		replace "\\d+" using "" options {search mode:grep, starting at top:true}
		-- Remove punctuation characters
		replace "[!?,.:;""'˜\"]" using "" options {search mode:grep, starting at top:true}
		-- Reduce space sequences to single spaces
		replace "[ ]{2,}" using " " options {search mode:grep, starting at top:true}
		-- Remove spaces at segment start
		replace "\\r[ ]" using "\\r" options {search mode:grep, starting at top:true}
		replace "\\t[ ]" using "\\t" options {search mode:grep, starting at top:true}
		-- Remove spaces at segment ending
		replace "[ ]\\r" using "\\r" options {search mode:grep, starting at top:true}
		replace "[ ]\\t" using "\\t" options {search mode:grep, starting at top:true}
		-- Remove duplicate lines
		process duplicate lines duplicates options {match mode:leaving_one} output options {deleting duplicates:true}
		-- Extract source segments with different translations
		process duplicate lines duplicates options {match mode:matching_all, match pattern:"^.*?\\t", match subpattern key:entire_match} output options {duplicates to new document:true}
		-- Extract identical translations stemming from different sources 
		process duplicate lines duplicates options {match mode:matching_all, match pattern:"\\t.*?$", match subpattern key:entire_match} output options {duplicates to new document:true}
	end tell
end tell

I found it, by comparing the whole script with a single command version:

 tell front text window
  

has to be:

 tell front text document
  

Don’t ask me why, but it works now :smiley: