Two Romanians are going to prison for recoding Dunkin' Donut gift cards with stolen bank account details and using them to withdraw money in New York City.

The men, who were in the United States on journalism visas, used dozens of the recoded Dunkin' Donuts gift cards to withdraw more than $17,700 from one ATM machine, prosecutors said. They were sentenced on Wednesday to three years in prison.

Daniel Gheorghe and Cristian Popa, both 33, were convicted of re-encoding the gift cards with stolen bank account information and then using them to withdraw money from a JP Morgan Chase bank in Queens.

The defendants should have used the Dunkin' Donut gift cards to purchase coffee and donuts, instead they have just bought themselves up to three years in prison. Justice has been served, Queens District Attorney Richard Brown said.

They doctored the rechargeable Dunkin’ Donuts cards with the stolen account information, essentially turning them into phony ATM cards. When they went to a Chase branch in Hollis in March and took out thousands from several different accounts, their scheme was unraveled.

Chase investigators called the NYPD. The officers bagged the thieves in the lobby of the Hillside Avenue bank as they stuffed money withdrawn from the ATMs into their pockets, prosecutors said.