in reply to untainting that which needs no untainting

Well, I'd change the regex to /(.*)/s. Just in case your $index_file name has a newline in the middle of it. I suppose that's not likely, but you asked us to put your mind at ease.
------------ :Wq Not an editor command: Wq