Learning spells from someone else’s spellbook and then selling it?

Learning spells from someone else’s spellbook and then selling it?

Basically, the character is a Spellcaster and he decided to visit a library in the town they’re currently staying at to find spellbooks or scrolls. I had him roll a die to determine what spells he would find. He rolled a 20 and just to annoy him a little (We are friends so it’s fine) I gave him a level 9 spell.

Now, at the time I had no idea that Spells level 9 can cost up to 50 thousand gold pieces and I also didn’t think that it was that big of a deal. In a nutshell, the character sold the book for 40 thousand gp but before he did it, he copied the spell into his own spellbook.

The money isn’t that big of a deal as the campaign won’t change drastically, but my concern is whether a character can copy a spell they find in their own spellbook and then get rid of the source.


Note: This is my first time DMing.