Now free of its ailing Eckerd drugstore chain, J.C. Penney ( JCP) Tuesday swung to a second-quarter profit, matching analysts' forecasts. It also cited strong back-to-school department store sales and improved gross margins. The mainly mall-based department store chain was upbeat about the current quarter, guiding earnings within range of the Wall Street consensus. Net income was $1 million, which because of preferred dividends translated into a loss of 2 cents a share in the second quarter. The company had break-even results, or a loss of 2 cents a share, a year ago. Results in both quarters included losses associated with the Eckerd division. Penney said earnings from continuing operations were 23 cents a share in the three months ended July 31, compared to a loss of 3 cents a share in the year-earlier period. Total sales were up 5.8% at $3.86 billion, with same-store department store sales up 7.1%. Same-store Internet and catalog sales dropped 1.6%, however. "Early back-to-school results are exceeding our expectations," said J.C. Penney Chief Executive Allen Questrom in a statement. During the quarter, Plano, Texas-based Penney completed the $4.5 billion sale of its Eckerd drugstore chain to both CVS ( CVS) and Jean Coutu Group, operator of the Brooks Pharmacy chain in the Northeast. The operating loss in the just-completed quarter related to the Eckerd sale was $71 million, net of taxes, the company said. Tuesday's results come as no shock, as the company upped its second-quarter earnings expectation to 22 cents a share on Aug. 2, well ahead of analysts' consensus estimate at the time. It also announced a $3 billion stock buyback program to be completed over the next year and a plan to retire $2.3 billion in debt. The moves are expected to improve the company's balance sheet by $8 billion. The company said Tuesday that operating profit in the second quarter jumped to $156 million, from $53 million in the year-ago quarter.