if you are writing to files and not a database, you are going to run into huge problems when more than one user visits the page at once.
The first php script i ever wrote was a hit counter. I had a txt file that had a number in it. Everytime someone visited the page, it would open the txt file, and add 1 to it, then save it. When two or more people visited my site at the same exact instance, on person would open the text file while the other was in the process of updating it. The result was that the hit counter woudl be reset to zero.
If this is what you are doing, i would recommend storing the results in a MySQL [or similar] database.