Investors in Countrywide Financial Corp. breathed a sigh of relief on Friday after the biggest U.S. after the biggest U.S. mortgage lender predicted it would regain profitability in the coming quarter and in 2008 after posting its first quarterly loss in 25 years.

The 40-year old lender has been hit hard by a downturn in the subprime market which peaked this past summer. The company recently announced a plan to reduce losses by modifying over $16 billion worth of loans. In its quarterly report released today, it listed $2.9 billion in write-downs and credit losses.

Countrywide made big bets on loans to borrowers with poor history. However the firm reported delinquencies in 29.08 percent of all so-called 'subprime' loans, up from 23.71 in June. It has virtually stopped making such loans.

After Countrywide announced problems in meeting its obligations to investors, it sought out credit lines from banking partners. Eventually it secured billions in needed funding. It even gained a big shareholder in Bank of America, which announced on August 22 it would pay $2 billion for preferred stock, stating at the time the company was undervalued.

On Friday, investors were pleased with the company's forecast, sending the stock up $4.23, or 32 percent to close at $17.30 on the New York Stock Exchange. Despite the gain, Countrywide's valuation has a long way to go before it fully recovers. The stock is still down 59 percent for the year.

The lender reported a $1.2 billion loss but said it expects to earn between 25 cents to 75 cents per share in the fourth quarter, down from $1.01 a year ago.

The company has already announced that it will eliminate a significant number of jobs. It is in the process of cutting 10,000 to 12,000 employees, which have so far cost the company $57 million, with another $70 million to $90 million in charges expected in the current quarter.

Its third quarter net loss was $2.85 per share, more than double the $1.28 loss expected by analysts polled by Thomson Financial.