Stocks have their first winning week since April

Signs that a solution to Greece's debt problems could be near helped the stock market eke out its first week of gains since April.

Germany softened its conditions for giving Greece more loans on Friday, putting Greece closer to getting more financial support and avoiding a default. Global financial markets were rattled earlier this week when a default by Greece seemed imminent.

Traders worry that a default by Greece could trigger another financial crisis, weakening the euro and leading to widespread losses for banks and governments that hold Greek bonds. A default would also push up the value of lower-risk assets like the dollar and U.S. government bonds.

The Dow Jones industrial average closed up 42.84, or 0.4 percent, at 12,004.36. The Standard & Poor's 500 index rose 3.86, or 0.3 percent, to 1,271.50.

The gains weren't widespread. The technology-focused Nasdaq composite index lost 7.22, or 0.3 percent, to 2,616.48 after signs that large companies are faltering.

BlackBerry maker Research In Motion Ltd. plummeted 21 percent after giving a surprisingly weak forecast for the current quarter and the remainder of the year. The company is struggling to compete with Apple Inc.'s iPhone and Android phones. Other technology companies like Intel Corp. and Cisco Systems Inc. fell 0.3 percent, the biggest drop among the 10 industries that make up the S&P index.

Among other U.S. companies, credit research firm Moody's Corp. dropped 5 percent after analysts downgraded the company. McGraw-Hill Cos., which owns rival rating agency Standard & Poor's, fell nearly 4 percent. And BJ's Wholesale Club Inc. dipped nearly 1 percent after two private equity firms made a bid for the warehouse club chain.

Germany's softer stance toward assisting Greece pulled the price of lower-risk investments like government bonds lower. The yield on the benchmark 10-year Treasury note rose to 2.94 percent early Friday from 2.90 percent Thursday. Bond yields rise when prices fall.

The S&P 500 finished the week just 0.04 percent higher than where it started. That tiny gain was enough to break a six-week losing streak that went back to the last week in April. The S&P 500 index hits its high for the year on April 29, and has fallen nearly 7 percent since then.

Nearly two stocks rose for every one that fell on the New York Stock Exchange Friday. Consolidated volume came to 4.4 billion shares.