The Messenger of Allah ﷺ said, "The fornicator is not a believer at the moment he commits fornication, the thief is not a believer at the moment he steals, and the drinker of wine is not a believer at the moment he drinks it. Yet the door of Tawba remains open thereafter."
حدثنا أبو صالح الأنطاكي أخبرنا أبو إسحق الفزاري عن الأعمش عن أبي صالح
قال رسول الله ﷺ لا يزني الزاني حين يزني وهو مؤمن ولا يسرق حين يسرق وهو مؤمن ولا يشرب الخمر حين يشربها وهو مؤمن والتوبة معروضة بعد
Bukhari narrated it in the Book of Hudud, Chapter: The sin of fornicators and the saying of Allah Most High, "and do not commit fornication", hadith no. 6810, and Muslim narrated it in the Book of Faith, Chapter: Explanation of the diminishing of faith through sins, etc., hadith no. 104/57, from the hadith of Amash, with the same wording.