(59) باب إِذَا هَمَّ الْعَبْدُ بِحَسَنَةٍ كُتِبَتْ وَإِذَا هَمَّ بِسَيِّئَةٍ لَمْ تُكْتَبْ
This hadith has been narrated with another chain of transmitters with the addition of these words:
Allah would even wipe out (the evil committed by a man) and Allah does not put to destruction anyone except he who is doomed to destruction.
Reference: Sahih Muslim 131 b
In-book reference: Book 1, Hadith 246
USC-MSA web (English) reference(deprecated numbering scheme): Book 1, Hadith 238