A 44-year-old man was sentenced Monday to 18 to 40 years in state prison for sexually assaulting a 6-year-old Bucks County girl, prosecutors said.

William E. McEvoy pleaded guilty in August in Bucks County Common Pleas Court to involuntary deviate sexual intercourse and related offenses.

A repeat offender, McEvoy, a Bucks County resident, pleaded guilty in 1994 to statutory rape for assaulting a 12-year-old girl in Bristol Borough.

In the latest assault, McEvoy molested the 6-year-old girl in the Bristol Township apartment she shared with her mother on Dec. 10, 2015. McEvoy exposed himself and then performed oral sex on the girl, prosecutors said.

The girl, now 8, submitted a letter to the court stating that McEvoy's assault "made me sad and scared. I was very mad because he hurt me. After he hurt me he told me not to tell my mom, but I did anyway. Since this happened I get scared at night and sleep in my mom's bed. I have been getting better and have started sleeping in my own bed again. I have trouble trusting people now, even my own dad."

McEvoy told Judge Jeffrey L. Finley that he was extremely drunk at the time of the assault, and that he has been drinking alcohol since he was 12 years old. He also told the judge he has been in and out of mental institutions since he was a child.

Finley ordered that McEvoy receive mental-health, substance-abuse, and sexual-offender treatment in prison.