A 33-year-old man who routinely provided a high school freshman with heroin in exchange for sex walked out of a Maryland courtroom a free man on Monday after pleading guilty to lesser charges.

Prosecutors said David Knox found the 15-year-old girl through the social media app, Whisper.

NEW EFFORT IN MARYLAND TO COMBAT UPSURGE IN FENTANYL DEATHS 

“I actually posted an ad online with my exact words, will f--k for dope,” the victim told WJLA during an interview in October 2018.

Knox and two other men independently replied to the ad placed by the teenager. According to court documents, between July 2017 and September 2017, Knox routinely traded the girl one gram of heroin for sex.

Prosecutors said Knox preyed on the girl’s raw vulnerability and should have known better.

"The defendant took advantage of a young girl with a drug problem," said a prosecutor with the Montgomery County State's Attorney's Office. "He was a full participant... knowing full well she was underage."

Knox’s defense attorney Christopher Wheatcroft admitted his client “made terrible choices” but said he’s “determined to not make future mistakes” and that “his sobriety is important for keeping his eye on the ball.”

4 MARYLAND HS STUDENTS CHARGED AS ADULTS IN ALLEGED BROOMSTICK LOCKER ROOM ASSAULT 

During sentencing, Knox apologized to the victim and her family.

"A lot of my actions, I believe, were controlled by my drug addiction," Knox said. "I hope the victim can get better from this and bounce back."

Montgomery County Circuit Court Judge Margaret Schweitzer sentenced Knox to four years of supervised probation. He is also required to register as a sex offender. She told Knox that she thought at his age he “would have exercised better judgment.”

CLICK HERE FOR THE FOX NEWS APP

During an interview with WJLA last year, the girl said she had experimented with 33 drugs including Adderall, crack, cocaine, LSD, marijuana, fentanyl, methamphetamine, morphine, oxycodone, PCP, Xanax and psychedelic mushrooms.

“Heroin was my first love,” she told the reporter. “I shot up every day, like multiple times a day. I could be sitting in a sewer and I could be bleeding to death, but then you shoot up some heroin and you’re the happiest person in the world.”