An Iowa father will spend the rest of his life behind bars for leaving his infant son alone in an apartment bedroom for nine days while maggots crawled over the boy and E. coli infected his bloodstream before he ultimately died, The Des Moines Register reported.

Zachary Koehn, 29, was convicted last month of first-degree murder and child endangerment causing death, the report said. He was sentenced Tuesday in Chickasaw County District Court.

IOWA MAN CONVICTED IN DEATH OF INFANT FOUND IN SWING

In August 2017, Koehn left his 3-month-old son, Sterling, in a baby swing in a bedroom for at least nine days with the windows covered and the door closed, according to the report.

Prosecutors said feces in the boy’s diaper ate through his skin, causing E. coli bacteria to enter his bloodstream and cause an infection. The hot room attracted flies that laid eggs, which hatched into maggots and crawled on the boy – while he was still alive. Meanwhile, Koehn and the boy’s mother, 21-year-old Cheyanne Harris, were caring for their 2-year-old daughter in the same apartment unit.

The boy eventually died from dehydration, malnutrition, and infection, weighing barely more than what he weighed at birth, prosecutors said.

Koehn “was aware of what was going on and he chose to do nothing,” Assistant Iowa Attorney General Denise Timmins said.

Koehn’s attorneys argued he should receive a new trial because the elements of the crime were not proven at trial and his actions didn’t amount to murder, but the motion was denied.

Harris was charged with first-degree murder and child endangerment causing death. Her sentencing trial is scheduled for late January. She has pleaded not guilty, according to The Register.

The Associated Press contributed to this report.