I'm so sorry. You tried so hard and did your best for him. He was a very fortunate little Betta to have you.
You saved him from a sad life living in a cup, perhaps to be sold to someone that would also keep him in a tiny little container, living for only a month or two at most.
His life may have been cut short, but rest assured he was happy, and knew you to be someone out there, looking in, who took care of him and was a friend.