If the utility/file system decides that a sector is not safe to use for whatever reason (maybe it cannot be read, or does not retain data), it marks it "bad", and no data is written there anymore.
A utility called SpinRite is really good at doing this. It can even test out "bad" sectors and return them to use if they work well enough.