AppleScript in Rule Not Working Consistently

I have a rule that monitors my downloads folder for continuing education certificates and appends them to an Evernote note for that event. It was working the other day, and now it keeps failing with error:
The rule is:

The file is named correctly:

The script that is running is:
Any help is much appreciated!
Can’t get item 1 of {}.
The rule is:

The file is named correctly:

The script that is running is:
- Code: Select all
(*
This version works from a Hazel rule.
Pass serial number from Hazel to AppleScript. Comes from here: https://www.noodlesoft.com/forums/viewtopic.php?t=1770&p=7294
*)
tell application "Finder"
set myHazelTokenDelimiters to "|"
set theListOfCustomTokens to name of theFile
set AppleScript's text item delimiters to {myHazelTokenDelimiters}
-- Now, the tokens are available in theListOfCustomTokens as items 1,2,3 etc...
set noteSerial to text item 2 of theListOfCustomTokens
-- set newFilename to "CE Certificate " & noteSerial & ".pdf"
-- set name of theFile to newFilename
set fileURL to POSIX path of theFile
end tell
(*
Based on: https://colterreed.com/how-to-append-to-evernote-notes-with-applescript/
Appends an entry to today’s Daily Record of Events in Evernote.
For best results, invoke the script from Keyboard Maestro or LaunchBar.
*)
tell application "Evernote"
set myNotebook to "\"Work Notes\"" -- set which notebook to search here
set searchString to "notebook:" & myNotebook & " " & noteSerial -- create an Evernote query string. See here: https://dev.evernote.com/doc/articles/search_grammar.php#Search_Terms
set matches to find notes searchString -- find note that matches both variables
set myNote to item 1 of matches -- this only works if there is only 1 match
open note window with myNote
-- add some tags (in progress)
--Append to the selected note
tell myNote to append attachment fileURL
tell myNote to append text fileURL
end tell
Any help is much appreciated!