Sensex, Nifty end flat for the week as IT rally offsets midcap weakness