When we manually edit a text file, we can go to a particular line, select the whole line, over-write it with some new text and then save the file.
When using fopen() and fprintf(), we can not really do this over-writing selectively, especially when the number of characters in that line is varying. If the text you are overwriting is always at the same position and the length is the same, you can use fseek() to find the position and then over-write the fixed-length of text.
In your case, the only option is to read the whole file, change the content as needed and then write to a different file. After it is done, you can use delete() and movefile() to delete the old file, rename the new file to the old file name.