Though it may require a shifting of gears mentally, I would suggest reading this in from an input box on the webpage, and then have your script called with that as a passed in parameter. Modifiying the code on the fly is dangerous, and creates a possible race condition if two users go for it at the same time. With a passed in parameter, each user gets their own "copy" of the program to do whatever they want to do with.