In July, Rite Aid (RAD 24.00%) posted same-store sales growth for the second straight month. Pharmacy and non-pharmacy (front-end) sales were both up, contributing to the company's 1.3% gain in same-store sales. Front-end same-store sales were up 0.7%, while pharmacy same-store sales were up 1.6% on a 0.4% increase in prescription count.

Rite Aid's recent return to same-store sales growth has buoyed investors' hopes. The company returned to profitability last year after many years in the red, and investors are expecting further improvement going forward. The stock has responded by surging to a multiyear high.

RAD Chart

Rite Aid 5-year stock chart. Data by YCharts.

While Rite Aid's July sales performance was encouraging, larger rival Walgreen (WBA -1.33%) far outpaced Rite Aid. Walgreen reported a 2.3% increase in comparable store front-end sales, while its comparable-store prescription count grew 9.5%. Altogether, comparable-store sales increased by 6.3%.

Walgreen's strong July results cast Rite Aid's performance in a different light. While Rite Aid is achieving nominal sales growth, it is losing a significant amount of prescription market share to Walgreen, because of the continued return of Express Scripts (ESRX) customers to Walgreens stores. This trend could make it difficult for Rite Aid to offset ongoing reductions in reimbursement levels, pressuring long-term profitability.

A new trend
The biggest change in Rite Aid's results over the past few months has been that the ongoing shift from brand-name drugs to generics has slowed. This shift has depressed revenue but boosted profitability (because generics are cheaper but offer much higher margins). For July, Rite Aid reported a 307-basis-point negative impact on pharmacy sales from new generic introductions, whereas the negative impact was as high as 695 basis points in February.

The significant increases in generic penetration seen over the past year have allowed Rite Aid to become more profitable in spite of declining sales. By contrast, with fewer new generics coming to market this year, Rite Aid could see a reversal of both trends -- i.e., increasing sales could be accompanied by falling earnings.

Reimbursement rates are key
Reimbursement rates -- the amounts paid by pharmacy benefit managers such as Express Scripts and CVS Caremark (CVS -1.07%) to pharmacies for various prescription drugs -- are perhaps the most important factor affecting Rite Aid's long-term profitability. Pharmacy benefit managers are constantly using their bargaining power to drive down the amount that they pay for prescription drugs.

Walgreen is regaining share from Rite Aid (i.e., growing sales faster), which would tend to boost its already strong profit margin. Strong increases in volume will allow Walgreen to offset the ongoing pressure on reimbursement rates.

Rite Aid won't have such an easy time coping with lower reimbursement rates. On Rite Aid's most recent earnings call, CFO Frank Vitrano described the reimbursement rate environment as "challenging." Indeed, that is the main reason the company projects that net income will decrease in the current fiscal year and adjusted EBITDA will remain approximately flat compared with last year's $1.13 billion.

Dueling forces
There are two big, long-term forces battling for control of Rite Aid's destiny. On one hand, the aging of the American population and Obamacare's extension of health insurance to more individuals are increasing the demand for prescription drugs. That increased demand benefits Rite Aid, Walgreen, CVS, and other, smaller pharmacies.

On the other hand, the market power of massive pharmacy benefits managers is constantly pushing down reimbursement rates and crimping pharmacies' margins. Since Rite Aid carries a heavy debt load and already subsists on lower margins than its main competitors, reimbursement rate pressure is a serious concern for the company.

If the benefit from higher prescription drug demand swamps the effect of falling reimbursement rates, all the major pharmacy chains will prosper. Rite Aid shares would be likely to perform particularly well, because it's heavily leveraged and has much lower profit margins than CVS or Walgreen today.

However, Rite Aid is also far riskier than the other two stocks. If pharmacy benefits managers become even more aggressive in cutting reimbursement rates, Rite Aid will be the first pharmacy chain to run into financial trouble. For most investors, the potential rewards for investing in Rite Aid can't justify assuming this risk.