Note that I did say "rewrite". The script has to write all changes back to the file before it finishes. In general, if the file is small, just overwrite the old file with the contents of the array.
There is one place where this "method" may cause problems. If two users hit the script at the same time and both induce some modification, you could end up with only one of the changes (the last one). This is why database systems are so very popular. They make sure all the changes get used, even during simulatneous usage.