Anthony Weiner submitted a guilty plea for having transferred obscene material to a minor on Friday.

Hours later, his wife Huma Abedin filed to end their marriage. Weiner faces 21 to 27 months in prison, and will be required to register as a sex offender under the plea deal.

“I have a sickness, but I do not have an excuse,” Weiner said of his three-month online affair with a 15-year-old high school student. “I apologize to everyone I have hurt. I apologize to the teenage girl, whom I mistreated so badly.”

The FBI began investigating Weiner in September after a 15-year-old North Carolina girl told a tabloid news site that she and the disgraced former politician had exchanged lewd messages for several months. She also accused him of asking her to undress on camera.

Weiner, a Democrat who represented a New York City congressional district for more than a decade, resigned in 2011 after a scandal over an explicit photo he accidentally sent from his Twitter account. Weiner later admitted that he had exchanged explicit messages and photos with at least six other women.

Weiner will live the rest of his life as a registered sex offender. He was forced to surrender his iPhone. In the courtroom, Weiner said, “I knew this was as morally wrong as it was unlawful.”