PLEASANTON, Calif. — Grocery store chain Safeway Inc. said Thursday its profit fell in the second quarter, partly on a tax charge related to a deal to sell its Canadian operations.

But the grocer's adjusted results topped Wall Street expectations, and shares rose in morning trading.

Safeway said in June it would sell its supermarket operations in Canada to food retailer Sobeys for 5.8 billion Canadian dollars ($5.7 billion). That followed its spinoff of its gift and prepaid card unit Blackhawk in April, in an IPO that raised $238 million.

"The substantial cash proceeds we expect to receive from the sale of our Canadian operations combined with the completion of the Blackhawk IPO will allow us to broadly enhance stakeholder value," said CEO Robert Edwards in a statement.

He added the company gained share in U.S. markets during the quarter.

Safeway and other traditional supermarket chains have been working to focus operations and keep costs low to fight off competition from big-box discounters such as Target and Wal-Mart Stores, as well as drug stores and dollar stores that have been expanding their grocery sections.

Safeway has invested in a loyalty program called "Just For U" that offers personalized deals based on a customer's past purchases, and has been expanding its offerings of store brands and trying to keep prices low to stay competitive.

The initiatives helped send Pleasanton, Calif.-based Safeway, which also operates Vons, sales at stores open at a least a year up 1.2 percent, excluding fuel. The figure is an important metric, because it strips out the impact of newly closed and opened locations.

For the period ended June 15, net income fell to $8.4 million, or 3 cents per share. That compares with net income of $122.7 million, or 51 cents per share, a year ago.

Adjusted for one-time items, including a 44-cents-per-share tax charge, increased legal reserves, a gain on the sale of investments, and other items, net income totaled 51 cents per share. Analysts expected 50 cents per share, according to FactSet.

Revenue fell nearly 2 percent to $8.7 billion from $8.83 billion, hurt by lower fuel sales. Wall Street expected $10.44 billion.

The company said it now expects net income for the year, excluding one-time items, to be at the lower end of its previously expected range of $2.25 to $2.45. Analysts expect $2.27 per share, on average.

It expects revenue in stores open at least one year to rise 1.5 percent to 2 percent.

Safeway shares rose $1.67, or 6.8 percent, to close at $26.32 Thursday, closer to the high end of the stock's 52-week range of $14.73 to $28.42.