I feel like Sherlock, if he were a developer

Your explanation that the code originally contained a variable for the filename is what actually explained the problem to me. When you used a constant in your explanation that “became” the problem. I (with 40 years of coding experience) simply could not understand why the procedure used 3 constants to specify the filename in a procedure to open a file. I still don’t like the code, but at least the explanation now makes sense.