U.S. stocks closed out their best week in four months on Friday on a flat note as strong earnings from IBM softened the blow of disappointing results from General Electric Co .

International Business Machines Corp , the world's largest technology services provider, rose 4.3 percent to $115.42 and pushed the Dow slightly higher after boosting its profit outlook for the year after the close on Thursday.

But fellow Dow components GE and Bank of America Corp reined in the blue-chip average's gains as Bank of America's soaring credit losses, along with GE's unexpected drop in revenue, curbed recovery optimism after promising earnings and data earlier in the week.

With companies such as Intel Corp and Goldman Sachs Group posting strong quarterly results earlier in the week, investors had been eager to see some consistency from other bellwether names.

Some optimism was priced into the earnings already after Goldman had a good quarter and the financials rallied, said Kevin Kruszenski, head of listed trading at KeyBanc Capital Markets in Cleveland.

The market has moved 7 percent this week, so it's time for a breather, Kruszenski added.

All three major U.S. stock indexes recorded their best week since mid-March, as both the Dow and the S&P 500 snapped four-week losing streaks.

For the week, the Dow rose 7.3 percent, the S&P 500 gained 7 percent and the Nasdaq climbed 7.4 percent.

GE's profit dropped nearly 50 percent as the slump that burdened its finance and media businesses spread to its industrial units, prompting Chief Executive Jeff Immelt to cut profit views for those parts of the company. The conglomerate's quarterly revenue fell 17 percent.

The Dow Jones industrial average <.DJI> gained 32.12 points, or 0.37 percent, to 8,743.94. But the Standard & Poor's 500 Index <.SPX> dipped just 0.36 of a point, or 0.04 percent, to 940.38. And the Nasdaq Composite Index <.IXIC> added 1.58 points, or 0.08 percent, to 1,886.61.

GE's stock shed 6.1 percent to $11.65 and led the S&P Industrials index <.GSPI> down 1.5 percent to 194.85. The stock was the Dow's top percentage decliner while the industrials index was the worst performer among S&P sectors.

Internet search giant Google Inc fell 2.8 percent to $430.25 on Nasdaq after a slump in advertising spending took a toll on Google's quarterly revenue growth, overshadowing results that topped Wall Street's forecasts.

Elsewhere, Citigroup Inc fell 0.3 percent, or just 1 penny, to $3.02, erasing slight gains made after it announced results. The big U.S. banking company relied on a gain from its Smith Barney deal with Morgan Stanley to turn a profit.

Helping sentiment was new data that showed U.S. housing starts and building permits jumped more than expected in June, propelled by a surge in single-family home starts.

The S&P 500 climbed as much as 40 percent from its 12-year closing low hit in early March before the run-up stalled in June. But the index has recovered from about a 7 percent loss since June's peak, based on an upbeat start to second-quarter earnings season, and is now up 39 percent from the March low.

Volume was light on the New York Stock Exchange, with 1.29 billion shares changing hands, below last year's estimated daily average of 1.49 billion, while on the Nasdaq, about 1.91 billion shares traded, below last year's daily average of 2.28 billion.

Declining stocks slightly outnumbered advancing ones on the NYSE by 1,498 to 1,469, while on the Nasdaq, about three stocks fell for every two that rose.

(Editing by Jan Paschal)