The Messenger of Allah, may Allah bless him and grant him peace, said:--
''Allah has written for the son of Adam (peace be upon him) his inevitable share of adultery whether he is aware of it or not. The adultery of the eye is the looking (at something which is sinful to look at), and the adultery of the tongue is to utter (what is unlawful to utter), and the inner self wishes and longs for (adultery) and the private parts turn that into reality or refrain from submitting to the temptation.'' [Sahih Bukhari]
Immodesty, obscenity and any form of adultery be it of the eyes, ears, tongue or thoughts makes a hole in the heart. Through this hole leaks out Imaan (faith). No matter how hard you try to fill your heart with Imaan, it will constantly flow out because of this hole. While an inappropriate thought may occur to anybody, as the Shaytaan is always trying to inspire people with such thoughts, yet it is the person who decides whether to entertain such ideas, discussions and temptations or turn away from them.
If you are on a plateau, the more centrally you stand on it, the safer you are. The closer you stand on its sides, the greater the danger that you might fall off its edge. So, to avoid major form of adultery, we must stay away from its minor forms, ie adultery of the eyes, tongue, ears and thoughts...doing this will make us safer. We should also avoid movies that glamorize the immoral, and avoid listening obscene talks...if an indecent thought occurs to us, we should seek refuge with Allah Subhanahu Wa Ta'ala from Shaytaan and not to entertain such thoughts.