As you need a persistent function (myEventHandler), you also need to target a persistent engine:
(As for the file problem in Windows, I suggest you google your question. AFAIK this is a known (boring) issue related to writing permissions in the C: drive or something like that.)
My apologies for a tiny bit of confusion. I was not looking for an answer to my Windows predicament. I was just whining. And I figured it out after about an hour of pounding the keyboard.
WRT the contribution to the main question I will give it a whirl soon and write back with my results.
Adding the #targetengine myEngine directive did indeed fix the problem. Thank you Mark.
Maybe it's too late, but for the future. For me these two lines
solved the problem.