Probably a faulty coil, ignition switch, or poor harness connection. When it cuts out, don't touch the ignition switch but immediately use a meter or test lamp to check for power at the coil connection coming from the key switch. If power is present, replace coil. if not, tract the circuit back to the fault.