Editing Flat-file database one line at a time

I am trying to edit just one line of entry in my flat-file database. I don’t have access to MySql or another database, so flat-files is what I have to work with. I would like to make an editor for a user selected row in my flat file, then submit the form and update just that row. I am not exactally sure how this will work and am looking for some input from you all.

Here is what I am thinking so far:

open file
feed file rows into array
loop until end of file{
put array info in variables (var0 = array[0] var1=[1] [2] etc...)

user selects array[0](array[0] is the 'key' I will use) variable in populated dropdown menu

information from array[0] populates form

user changes form data

push submit and form fields update array[] and therefor the line of text that was grabbed to be edited.

Do I need to use 2 arrays? One to hold the KEY and then another that is linked to the KEY holding the data in order to populate the form field?

or… and how can i over-write one line of a text file?

Thanks for any ideas!