mmerlinn,
STUFF works on a memory variable, not a file. You can do FILETOSTR(), STUFF() and STRTOFILE(), but you finally rewrite the whole file. You can overwrite file content via FWRITE, as said, but you can neither skip bytes, if the new text you want to write is shorter, nor add bytes, if the newly written bytes are more than you want to overwrite.
STUFF just uses a new memory segment, copies the left part of the old string, adds the new part, adds the right part of the old string, and lets the string variable point to that new memory address. STRTRAN does similar things repeatedly at each position a searched string is found. But there is no magic of allocating new bytes to add somewhere in the middle of an already allocated memory block or within a file block.
If you would need to stuff in something in the third line counted from the end of the file, it would be advisable to SEEK near to the end, read in the last lines, then FSEEK to the position where you need to overwrite and then just modify that part, after which you add the read in lines. But for the first or second line, a rewrite of the whole file is much easier, you always have to rewrite everything after the inserted line anyway.
That's also the reason the deletion of a row just marks the row deleted and doesn't remove it, that file modification would have the high cost to rewrite everything at the position of the removed record, and this cost is highest for the first lines or records.
The only way to make this as you want is to initially have enough bytes in the second line to put in your replacement line. Maybe you can at least modify or influence the initial file creation to generate a long enough line. And if you just can make it longer than needed, the best fit for the unused bytes would of course be spaces. The same way VFP pads unused bytes of a char field with spaces.
Bye, Olaf.