Stocks struggle for gains, but Nasdaq rises