A homeless man became a hero in State College, Pennsylvania, when he returned a purse containing nearly $400 and a welfare card to a single mother struggling with recurrent brain cancer.

After finding the pocketbook on a park bench, the man in his late 30s wrestled with his conscience and texted Ashton Munoz, assistant director for Hearts for Homeless shelter.

"He said, 'I found this purse. There's money in it,'" Munoz recalled on Friday, explaining that the shelter provides its clients with cell phones with prepaid minutes.

Black mens wallet lying outdoors on a wooden bench. Pelfophoto / Shutterstock

Trending stories,celebrity news and all the best of TODAY. This site is protected by recaptcha

In the text sent late on Wednesday night, the man asked Munoz to come pick up the purse, explaining that the temptation to take the money was becoming overwhelming.

"I drove in," Munoz said. "We were able to identify the owner."

She is in her mid-to-late 20s and is the single mother of one child. She is struggling with a second episode of brain cancer, Munoz said.

"She had gone to the park to relax," he said. "She set it on a park bench and forgot it was there. When she went back several hours later, it was gone. She was pretty devastated."

Munoz and the homeless man returned the purse to the woman, who was relieved to recover her money and electronic benefits (EBT) card, used to access food stamps.

She told a reporter for WJAC-TV 6 in Johnstown that she felt her entire life was in the purse and she was glad to have it back. After the story was posted on the station's website, praise poured in from viewers.

"AWESOME..." Kathy Mae commented online.

"There are good people in the world," Rita Showalter Detwiler agreed.

Munoz told Reuters that the homeless man, who had been living on the street, has been struggling to get his life back on track. In part because of his good deed, the shelter has moved him into a transitional apartment.

Both the man and the woman declined to be identified by name.