It was an almost lucky day for a homeless man in Maine who received an unexpected 'gift' from a South Portland TD Bank ATM machine on Thursday.

The homeless man, whose identity has not been revealed, originally used the ATM machine to take out $140. But then, the machine just kept going and going, giving the homeless man a whopping total of $37,000.

The incident occurred early Thursday morning at around 5:30 a.m. As the man began collecting money from the machine, another woman entered the bank.

The woman stood behind the man for an extended period of time and grew suspicious of the large sum of money that the man appeared to be collecting. That's when she took action and called the police.

She reported to South Portland police officials that the man was spending an unusually long amount of time at the machine.

Upon arrival, South Portland police officers found the homeless man stuffing the large sum of money into a big shopping bag.

The money was quickly returned to TD bank and fortunately no customers were affected by the potentially detrimental ATM glitch. A bank official described the glitch as a "code error" within the ATM machine's system.

TD Bank has announced that they will not press charges and the homeless man was sent on his way.

"I think that's really nice of them, and I think it's the right thing to do. Obviously he was kind of tricking the system a little bit. But it was partially their fault for not having the right security on it," said area resident Sarah Howard to WGME news. Area resident Maria Giancola also commented, "If the bank was giving it, he wasn't stealing it. He was just playing the slot machine, so to speak."

According to South Portland police officials, this isn't the first time they've had an encounter with the homeless man. That same Thursday at 1 a.m., the police found the man sleeping inside the bank near the same ATM. They moved him along, however the man came back and almost got away with claiming a $37,000 cash withdrawal.

Since the incident, the South Portland TD Bank ATM has been labeled "Out Of Order."

Should TD Bank press charges or was it just this man's lucky day? Share your comments with us below.