Why don't you first open the file for input only, read and store each line in an array of strings. Close the file Change the line you want to change. Then open the file for output and write each line in the same order. Then save the file. Since .ini files are not that large, this should work very well.