An agreement has been reached to sell a Philadelphia institution to a Georgia-based company.  

The goal is to keep Tastykake alive and expand its reach. Thomasville Georgia-based Flowers Foods has agreed to buy the struggling baking company for about $34 million in cash plus assumption of debts. The total deal is worth $165 million. Mary Krier is a spokesperson for Flowers Foods.

"We could not be more excited about the opportunity that this merger presents for Flowers and for Tastykake," Krier said. "It insures that the beloved Tastykake's will be made for Philadelphians in Philadelphia."

The company will also sell Tastykakes in areas where Flowers currently operates, including 4,000 independent distributors covering 61 percent of the country.

The deal works out to $4 a share for Tastykake stockholders--more than double the company's stock price at Friday's close of trading.