Rite Aid (RAD 25.83%) reported this week that its earnings per share totaled $0.04 last quarter, but the news did little to boost share prices, which have been sliding since the company lowered its full-year earnings outlook on June 5th.

Rite Aid's dampened expectations are due to lower-than-expected profit on the sale of generic medicine. That news is concerning given that generic drugs offer higher profit margin than their branded counterparts, and more drugs are losing patent protection this year than last year.

Since Rite Aid blamed its profit troubles on its new generic purchasing and distribution deal with McKesson (MCK 0.47%), let's take a closer look.

Source: Rite Aid.

Solid, yet disappointing
Rite Aid's revenue totaled $6.5 billion in the quarter, up from $6.3 billion last year. That's particularly impressive given that the company closed a net of six stores during the quarter, bringing its total store count to 4,581, down from 4,614 a year ago.

The 2.7% revenue gain is entirely thanks to better sales in the pharmacy. Rite Aid's same-store sales grew by 3.1% in the quarter; however a 4.6% jump in pharmacy revenue masked lackluster front-end sales, which were flat compared to a year ago.

Source: Rite Aid

Importantly, the jump in pharmacy sales wasn't driven just by pricing. In fact, revenue growth would have been 1.4% higher if not for the introduction of new, cheap generic versions of drugs like Lilly's former blockbuster Cymbalta, which lost patent protection in December.

However, lower revenue from those generic introductions was more than offset by rising prescription volume, ostensibly supported by expanding insurance coverage tied to health care reform. In the quarter, Rite Aid filled 2.3% more prescriptions than a year ago (again impressive given the declining store count).

So, what drove profit below prior guidance?
Despite rising script volume driving sales higher, the biggest reason for the profit shortfall is what now appears to be overly rosy guidance for cost-saving benefits tied to Rite Aid's recent deal with generic distribution giant McKesson.

That deal transferred the company's responsibility for buying and distributing generic drugs to stores from Rite Aid to McKesson. When the deal was announced, Rite Aid argued that McKesson's bigger buying power and sophisticated distribution network (allowing for daily shipments direct to stores) would lower purchasing costs and inventory.

Unfortunately, that argument fell short this past quarter given that the company's cost of goods sold totaled 72.1%, up about a percent from a year ago.

Source: Rite Aid

All is not lost
Rite Aid is convinced that the headwinds from the McKesson deal will ease as the year progresses.

The company reaffirmed expectations released on June 5th for the full fiscal year, projecting that its earnings will reach $0.30 to $0.40 per share; handily outpacing the $0.23 it earned in fiscal 2014.

Those earnings will come on sales of $26 billion to $26.5 billion as same-store sales are expected to grow between 2.5% and 4.5% this year.

The return to top-line growth is particularly intriguing given that the company operates far fewer stores thanks to a restructuring that's unloaded underperforming locations.

If Rite Aid can continue to grow its top line amid store closures, its profitability could improve nicely once it returns to expansion. Rite Aid's stores are mostly found on the east and west coasts and are conspicuously absent from key retirement states like Texas and Florida. If the company's acquisition of the Texas-based retail store clinic chain RediClinic in February is an indication of a willingness to start moving into these markets, profit could benefit.

That's because the company has done a nice job controlling its SG&A expense, which dropped from 25.6% of sales to 25.4% over the past year. Rite Aid also continues to improve its balance sheet, cutting its interest expense. Total debt dropped from $5.9 billion a year ago to $5.7 billion in May.

Fool-worthy final thoughts
Generic introductions will continue to weigh down the top line but should support earnings through 2015. Pharmacies historically earn a margin of nearly 50% on the sale of generics versus just 10% for brand drugs. $34 billion in branded drugs will go off-patent this year, and another $66 billion will lose exclusivity next year, suggesting there's plenty of profit-friendly launches heading Rite Aid's way. If McKesson can deliver on its cost-saving promise, Rite Aid's results could come in closer to the high end of its full-year guidance than the low end.