What's happening in the nail is that that all those magnetic domains are scattered higgledy-piggledy in all directions. By exposing the domains to a magnet stroking along the surface of the nail, you care coaxing all those little domain to align with the motion of the magnet. use the nail to attract different bits of iron for a bit, and you will notice the effect wear off. What do you think it happening that makes the needle not a magnet?