All perfect praise be to Allah, The Lord of the Worlds. I testify that there is none worthy of worship except Allah, and that Muhammad,
, is His slave and Messenger.
Since you had only intended to forgive your friend from having to repay you the loan, then it is permissible to get back the money that you had lent him and you are not sinful in doing so.
Allah knows best.