Do you get any errors in the log? If so, what are they?
I suspect the Select Where is running too soon, because the file is opening, which JMP will do in the background. Try putting the line
dt << rerun formulas;
after the open() and see if that works.
What I usually do with code like this, is to run lines 1&2. Find the first file that ends in .dat, and set your "filename' to its value, and then run one at a time, the open, select where, delete and close lines to see what happens.
Jim