I'm trying to write some code that will read in a file, check to see if a line needs to changed, and then changes it if necessary. Right now it seems to me that I have to open the file for reading, read it all into an array, close the file, edit the array, open the file again and overwrite the old file with the edited array. Is there a more elegant way to do this?