Rite Aid (RAD) posted a narrowed second-quarter loss on Thursday despite virtually flat sales from the same period in 2011, and lowered its full-year sales forecast.

Helped by improved front-end sales, a stronger prescription count and a decrease in certain restructuring costs, the pharmacy chain reported a net loss of $38.8 million, or 5 cents a share, compared with a year-earlier loss of $92.3 million, or 11 cents a share.

The results were better than the 7-cent loss forecasted by analysts in a Thomson Reuters poll.

However, revenue for the three months ended Sept. 1 was $6.2 billion, down 0.6% from $6.3 billion a year ago, narrowly below the Street’s view of $6.21 billion. Same-store sales, a key growth metric for retailers that measures sales at stores open longer than a year, were flat year-over-year.

While admitting that the “wave of new generic medications is negatively impacting same-store sales,” Rite Aid said the influx of cheaper generics is having a positive impact on its pharmacy gross margin.

“We are pleased with our second quarter results as we continue to make significant progress in our turnaround efforts,” Rite Aid John Standley said in a statement.

The company said it operates more efficiently and has improved the customer experience with the help of an overhaul that has so far closed several unprofitable stores.

The Camp Hill, Pa.-based company lowered its fiscal 2013 sales forecast to a range between $25.1 billion and $25.4 billion on a decline of same-store sales of 1% to an increase of 0.25%.

Analysts are currently looking for stronger sales of $25.42 billion.

Shares of Rite Aid fell about 3% on Thursday

Follow Jennifer Booton on Twitter at @Jbooton