in reply to Reading and manipulating text files
This is not related to the question you asked, but I would like to note the impressive list of things you did right in your script:
Keep up the good work.