Stocks on Wall Street shook off a weak start and closed slightly higher, snapping a four-week losing streak.