It is narrated from Sayyiduna Ibn Mas'ud (may Allah be pleased with him) that the Messenger of Allah (peace and blessings be upon him) said: "A servant is born a believer, lives as a believer, but dies a disbeliever. And a servant is born a disbeliever, lives as a disbeliever, but dies a believer. And a servant spends part of his life doing the deeds of the fortunate, then what was written for him overtakes him, and he dies wretched. And a servant spends part of his life doing the deeds of the wretched, then what was written for him overtakes him, and he dies fortunate."
Hadith Referenceالمعجم الكبير للطبراني / باب العين / 10496