Basically the logic of experience orbs. If you die, you can't enchant. Makes enchanting kinda like a reward (if a hard to get one).