in reply to providing filenames dynamically

I suggest you read Basic debugging checklist.