John 8:6-11, "They were saying this, testing Him, so that they might have grounds for accusing Him. But Jesus stooped down and with His finger wrote on the ground. 7 But when they persisted in asking Him, He straightened up, and said to them, “He who is without sin among you, let him be the first to throw a stone at her.” 8 Again He stooped down and wrote on the ground. 9 When they heard it, they began to go out one by one, beginning with the older ones, and He was left alone, and the woman, where she was, in the center of the court. 10 Straightening up, Jesus said to her, “Woman, where are they? Did no one condemn you?” 11 She said, “No one, Lord.” And Jesus said, “I do not condemn you, either. Go. From now on sin no more.”
We don't know exactly why Jesus wrote on the ground during the episode of the woman caught in adultery, but it might be that Jesus was referring to the Old Testament passage found in Jeremiah.
Jeremiah 17:13, "Lord, hope of Israel, those who leave you will be shamed. People who quit following the Lord will be like a name written in the dust, because they have left the Lord, the spring of living water."
Since the Jews in Israel were legalistic and probably in sin themselves (and they knew the Old Testament Scriptures), the writing in the ground may very well have reminded them of the Jeremiah passage. So, Jesus may have been writing out their sins.