When using an ordinary text file where each field is of variable length, it isn't possible to update the file data 'in-place' unless the new values are of exactly the same length as the values being replaced. Since the length of the name and program (and also possibly the ID) could be different, there is no alternative but to re-write the entire file.
A relatively easy way to do this is to read the entire file into an array or vector. To keep control of the data for each individual student, you might use a structure to hold the data for one student, and create an array of student objects. Modify the values in the array, and write the entire array out to a fresh version of the file.
Another way is to read the data one record at a time (again using a struct could help). If the id matches the requested value, change the data before writing it out. Otherwise write out the unchanged data. Note: this approach avoids the need for storing more than a single student record at a time. However it does require two physically separate files, the original and the updated version.