Shares end the week higher but foreign investors still flee the market