Gold ends higher, but suffers a weekly loss