Improving the ruby script with poor man's file handling