We present a new empirical prescription for the mass-loss rates of carbon and oxygen sequence Wolf-Rayet stars as a function of their luminosity, surface chemical composition, and initial metallicity. The new prescription is based on results of detailed spectral analyses of WC and WO stars, and improves the often applied Nugis & Lamers (2000) relation. We find that the mass-loss rates of WC and WO stars (with $X=0$ and $Y < 0.98$) can be expressed as $log{dot{M}} = -9.20 + 0.85log{(L/L_{odot})} + 0.44log{Y} + 0.25log{(Z_{mathrm{Fe}}/Z_{mathrm{Fe}, odot})}$. This relation is based on mass-loss determinations that assume a volume-filling factor of 0.1, but the prescription can easily be scaled to account for other volume-filling factors. The residual of the fit is $sigma = 0.06$ dex. We investigated whether the relation can also describe the mass loss of hydrogen-free WN stars and showed that it can when an adjustement of the metallicty dependence ($log{dot{M}} propto 1.3log{(Z_{mathrm{Fe}}/Z_{mathrm{Fe}, odot})}$) is applied. Compared to Nugis & Lamers (2000), $dot{M}$ is less sensitive to the luminosity and the surface abundance, implying a stronger mass loss of massive stars in their late stages of evolution. The modest metallicity dependence implies that if WC or WO stars are formed in metal deficient environments, their mass-loss rates are higher than currently anticipated. These effects may result in a larger number of type Ic supernovae and less black holes to be formed, and may favour the production of superluminous type Ic supernovae through interaction with C and O rich circumstellar material or the dense stellar wind.