U.S. stocks gain; Dow closes at record high