Find particular word in a document using TextEdit or BBEdit

I am attempting to open a text document within either TextEdit or BBEdit and set a particular word to a variable.

The code I have set up thus far is:

set chosenFile to (choose file) as string

tell application "TextEdit"
	activate
	open file (chosenFile) --with LF translation
	set custID to the first word of line 11
	return result
end tell

No matter which application I use I get an error that tells me the app cannot retrieve the first word of line 11.

Anyone know how to retrieve this information?

More specifically, the error I am receiving is this:

"TextEdit got an error: NSCannotCreateScriptCommandError"

Hi,

I don’t think there is a ‘line’ object n TextEdit.

gl,

Sorry the line comment was a hangover from when I was trying to accomplish it in BBEdit… but I figured out what I needed to do. Here is the code that works:

set chosenFile to (choose file) as string

tell application "TextEdit"
	activate
	open file (chosenFile)
	tell front document
		copy (the first word of paragraph 11) to custID
	end tell
end tell