sed -i is unreliable