If you're talking about a plain text file, you don't have any way to tell it to write a certain line. The best you can do is sequentially process the entire file, reading it from one file and writing it to a new one, and modify the desired line on the fly, or else read the entire file into an array in memory, modify the desired line and then write the whole thing back.
It sounds like you are really talking about database-type functions, in which case you really really do need a database.