If each line of text can be variable length, then you cannot just overwrite it.
I would suggest the following.
Use file_copy to copy the original file to a temporary file. Open the temporary file. Open an output file with the name of the original file. Read the temporary file; if the line is not the line you want to change, then write it to the new output file; if the line is the line you want to change (data file:= ) then write the new line to the output file. Close the temporary file and delete it if it is un-needed. Close the output file. It is brute force, but it works.
If lines are fixed lengths (always, say, 1000 characters and always blank padded) then you would know exactly which bytes to overwrite, and you could always go to the correct part of the text file; you need to be careful of the "end of line characters" of which there can be either one or two, depending on the OS.
|