Like Mike said, you need to bump up the fuel cost a bit (6 gals per hour x $4.50 to $5.00 per gal x 150 hrs). Add in insurance. Also, figure in "cost of money". If you're getting a loan, figure in the interest. If you already have the money, that cash can earn some interest if not tied up in the plane. So, there's still a monetary advantage for you in buying vs renting, but it's less than $8K.
It may appear that we seem to be trying to talk you out of buying, but we're just playing devil's advocate. On average, only 25% of student pilots go on to finish their training, due to work, family time, shortage of money, loss of interest, medical problems, etc. We just hate to see you get stuck with an airplane if you don't get your PPL for one reason or another.