S&P marks worst record since December as US exchanges post weekly losses