File returns after delete

I’m working on an Apple Script which once a file is downloaded into a folder, it opens the file gets the contents then closes it and deletes it. On occassion after the file deletes a file of the same name appears in the folder. This file has no contents. Here is my script:

on adding folder items to this_folder after receiving added_items
	delay 1
	--if file "Macintosh HD:text:link.txt"
	--opens link.txt and gets its contents
	set theFile to (open for access file "Macintosh HD:text:writefile.asp" with write permission) as text
	set fileContents to (read theFile)
	try
		close access theFile
	end try
	--Closes IE windows
	tell application "Internet Explorer"
		CloseWindow Title "Download Manager"
		CloseWindow Title "thiswindow"
	end tell
	--grabs the file name from the text doc
	set fileName to text 11 thru 18 of fileContents
	
	--deletes link.txt and empties the trash
	tell application "Finder"
		delete file "Macintosh HD:text:writefile.asp"
	end tell

the rest of the script takes the contents and does something with it

end adding folder items to

Any ideas on how I can fix this?

HERE. This code line creates second object (add new file to HOT folder), and triggers from this code line folder action before you complete the previous processing. From here you lose control on your HOT folder.


on adding folder items to this_folder after receiving added_items
	delay 1
	set fileContents to (read file "Macintosh HD:text:writefile.asp")
	
	--Closes IE windows
	tell application "Internet Explorer"
		CloseWindow Title "Download Manager"
		CloseWindow Title "thiswindow"
	end tell
	
	--grabs the file name from the text doc
	set fileName to text 11 thru 18 of fileContents
	
	--deletes link.txt and empties the trash
	tell application "Finder" to delete file "Macintosh HD:text:writefile.asp"

the rest of the script takes the contents and does something with it

end adding folder items to