Removal of impurities from tokamaks by neutral-beam injection