So you are storing eash record in a line, dilineated by a |--Id also recommend a line num, so its like:
$num|$var|$var|$var
That way you know which line you are going to edit. The rest is all in the manul---check out the assorted filesystem functions for adding/editting/deleting rows from a text file.