Hadeeth 4: 4 Things Written...
On the authority of Abdullah ibn Masud (may Allah be pleased with him), who said: The Messenger of Allah (peace be upon him), and he is the truthful and the believed, narrated to us:
Verily the creation of each one of you is brought together in their mother's womb for forty days in the form of a drop, then he becomes a clot of blood for a like period, then a morsel of flesh for a like period, then there is sent to them the angel who blows the soul into them and commands with four matters: to write down their sustenance, their life span, their actions, and whether their will be happy or unhappy (whether or not he will enter Paradise).
By Allah, other than Whom there is no deity, verily one of you performs the actions of the people of Paradise until there is but an arm's length between them and it, but that which has been written for them overtakes them, and so they act with the actions of the people of the Hellfire and thus enter it; and verily one of you performs the actions of the people of the Hellfire, until there is but an arm's length between them and it, and but then that which has been written for them overtakes them and so they act with the actions of the people of Paradise and thus enter it.
Reported by Bukhari and Muslim