I'm not very good with PHP, but I think I've worked out what you are doing and therefore what you are doing wrong.
You are taking the previous average from the file then adding the current roll to it, then dividing by the number of rolls.
What I think you should be doing is keeping a list of...