An alternate version:

Once upon a time there existed somewhere in the world, nobody knows where, a school which was called the Black School. There the pupils learned witchcraft and all sorts of ancient arts. Wherever this school was, it was somewhere below ground, and was held in a strong room which, as it had no window, was eternally dark and changeless. There was no teacher either, but everything was learnt from books with fiery letters, which could be read quite easily in the dark. Never were the pupils allowed to go out into the open air or see the daylight during the whole time they stayed there, which was from five to seven years. By then they had gained a thorough and perfect knowledge of the sciences to be learnt. A shaggy gray hand came through the wall every day with the pupils' meals, and when they had finished eating and drinking took back the horns and platters. But one of the rules of the school was, that the owner should keep for himself that one of the students who should leave the school the last every year. And, considering that it was pretty well known among the pupils that the devil himself was the master, you may fancy what a scramble there was at each year's end, everybody doing his best to avoid being last to leave the school.

It happened once that three Icelanders went to this school, by the name of Saemundur the Learned, Kalfur Arnason, and Halfdan Eldjarnsson; and as they all arrived at the same time, they were all supposed to leave at the same time. Saemundur declared himself willing to be the last of them, at which the others were much lightened in mind.

So when it came time to leave and Saemundur mounted the staircase that led to the upper world, the Devil came for him. When he was near the top the sun shown down on him and cast his shadow behind him. He said "I am not the last. Do you not see who follows me?" and the Devil seized the shadow, mistaking it for a man, and Saemundur escaped with a blow on his heels from the iron door (saying: "That was pretty close upon my heels," which words have since passed into a proverb).

But from that hour he was always shadowless, for whatever the devil took, he never gave back again.
Source: Folklore and Mythology Electronic Texts, edited or translated by D. L. Ashliman. (