append try and except controlling
sed '/,\ file=sys\.stderr/ { s/print/sys\.stderr\.write/; s/,\ file=sys\.stderr//;}'