He walked on and on for hours , the sun beating hotly on his head , and his legs trembling under him , and he might have died of thirst if he had not suddenly stumbled on a little well , which looked as if it had been newly dug .