Sahih Muslim Book 33, Hadith Number 6392.
Chapter : The growth of a child in the womb of a mother and his destiny in regard to his livelihood, his deeds. both good and evil.
Hudhaifa b. Usaid reported directly from Allah’s Messenger (may peace be upon him) that lie said: When the drop of (semen) remains in the womb for forty or fifty (days) or forty nights, the angel comes and says: My Lord, will he be good or evil? And both these things would be written. Then the angel says: My Lord, would he be male or female? And both these things are written. And his deeds and actions, his death, his livelihood; these are also recorded. Then his document of destiny is rolled and there is no, addition to and subtraction from it.