2,270. How to Overcome the Urge
Hilchos Issurei Biah 22:20
It’s appropriate for a person to subdue his natural desires in sexual matters and condition himself with extra holiness, purity of thought and good traits in order to guard against them. One should be cautious not to seclude himself with a woman, which leads many to sin. The Sages would tell their students to watch them because of their own daughters or daughters-in-law, from which the students would learn not to be embarrassed about these things and to distance themselves from seclusion with women.
Hilchos Issurei Biah 22:21
A person should likewise distance himself from frivolity, drunkenness and flirting because these things lead to prohibited relations. A man shouldn’t go without a wife because being married facilitates greater purity. The Sages emphasized that a man should always turn himself and his thoughts towards words of the Torah and grow in wisdom because thoughts of prohibited relations are only cultivated in a heart that lacks wisdom. Proverbs 5:19 tells us that “It (i.e., the Torah) is a beloved hind and a graceful doe. Let her breasts satisfy you at all times. With her love you will be ravished.”