U.S. stocks finished higher in the final session of the week, putting an end to the three-week losing streak.