Meh, I have little/no experience with handling files myself. Might be easier, though, for you to modify some existing code? There’s already been a lot of very sophisticated work done in statsgathering. I’m thinking of Reinvigorate, for example – not trying to discourage you, just find the most practical solution? I mean, are you in it purely to make the plugin or is there some ulterior motive?