Inter-company debt on sale

Company A and Company B are owned by the same person, who is also the sole director of both companies.

Company A is a trading company, company B owns the building that company A trades from and also owns the copyright to the products company A owns.  It also pays a salary and dividends to the owner - company A does not pay the owner.

Apart from rent, company B has never made any charge for royalties or management charge to company A.

 

The owner now wishes to retire to Crete and wishes to sell company A, but retain company B, although as part of the sale he would transfer the copyright to company A and then company B would simply rent the building to company A.

Over the years, company A has transferred money to company B such that company B owes company A approximately £450K but has only £200K cash and negligible distributable reserves.  As part of any sale agreement the owner would like this £450K written off.

What would be the best way to write this off to prevent any adverse effect on company A, which will continue to trade under new ownership?