Follow what dragonchild has advised above. But also note... no matter which way you do it, you are opening a file, changing its contents, writing it out again to replace the existing file. If you have many different modifications to make, you could tie the entire file contents to a hash, and then as you make changes to the contents of the hash, it would make the changes to the file for you. But you can't just change the contents of a file without rewriting it out... if that is what you want then you need a database of some sort. The simplest would be DB_File.