save new document error

I am using textedit to create a document and then save it. When it gets to the save step I get this message in the event log:

save document 1 as text in "Beow27:Users:mkaz:Documents:Homepage:mrev:xx.txt"
	--> error number -10000

The dialog box error is:

“The document xx.txt could not be exported as xx.txt. You don’t have permission.”

I know this is something simple, it has eluded me.

Thanks!

tell application "Mail"
	set selectedMessages to selection
	if (count of selectedMessages) is equal to 0 then
		display alert "No Messages Selected" message "You must select a message first."
	else
		repeat with i from 1 to count of selectedMessages
			set theMessage to item i of selectedMessages
			set theSub to subject of theMessage
			copy (display dialog theSub & " Enter file name:" buttons {"OK", "Cancel"} ¬
				default button "OK" default answer ".txt") to dialogResult
			if the button returned of dialogResult is "Cancel" then quit
			copy the text returned of dialogResult to arg
			set theFilename to "Beow27:Users:mkaz:Documents:Homepage:mrev:" & arg
			set theContent to content of theMessage
			set theSub to subject of theMessage
			set thedate to date sent of theMessage
			tell application "TextEdit"
				activate
				make new document
				tell the front document
					set paragraph 1 to "Subject: " & theSub & return & "Date: " & thedate & return & return & theContent
				end tell
save the front document as text in theFilename  -- Where it crashes
				close the front document
			end tell
			tell application "Mail"
				activate
			end tell
			tell application "Finder"
				open "Beow27:Users:mkaz:Documents:Homepage:mrev"
			end tell
		end repeat
		tell application "TextEdit"
			quit
		end tell
	end if
end tell

Hi,

TextEdit is not needed to create a plain text file


set destinationFolder to (path to documents folder as text) & "Homepage:mrev:"
tell application "Mail"
	activate
	set selectedMessages to selection
end tell
set countMessages to (count of selectedMessages)
if countMessages is equal to 0 then
	display alert "No Messages Selected" message "You must select a message first."
else
	repeat with i from 1 to countMessages
		tell application "Mail"
			set theMessage to item i of selectedMessages
			set {content:theContent, subject:theSub, date sent:thedate} to theMessage
			set arg to text returned of (display dialog theSub & " Enter file name:" default button "OK" default answer ".txt")
			if arg does not end with ".txt" then set arg to arg & ".txt"
			set theFilename to destinationFolder & arg
		end tell
		try
			set fRef to open for access file theFilename with write permission
			write "Subject: " & theSub & return & "Date: " & thedate & return & return & theContent to fRef
			close access fRef
		on error
			try
				close access file theFilename
			end try
		end try
	end repeat
	tell application "Finder" to open folder destinationFolder
end if

Thanks!