If Hoarding Dragon dies before its second ability resolves, its third ability will trigger and do nothing. Then its second ability will resolve. If you choose to exile an artifact card from your library, it will be exiled indefinitely.

Artwork
Loading artwork…
Hoarding Dragon
Foundations · #626 · EN
Nonfoil—Foil—
Card rules
Flying
When this creature enters, you may search your library for an artifact card, exile it, then shuffle.
When this creature dies, you may put the exiled card into its owner's hand.
4/4
Uncommon · Illustrated by Matt Cavotta
Format legality
Alchemy Legal
Brawl Legal
Commander Legal
Competitive Brawl Legal
Duel Legal
Future Legal
Gladiator Legal
Historic Legal
Legacy Legal
Modern Legal
Oathbreaker Legal
Penny Legal
Pioneer Legal
PreDH Legal
Standard Legal
Standard Brawl Legal
Timeless Legal
Vintage Legal
Old School Not Legal
Pauper Not Legal
Pauper Commander Not Legal
Premodern Not Legal
Tlr Not Legal
Rulings
Published rulings from the downloaded Scryfall catalog. Source card record · Rules and interactions
The artifact card you find is exiled face up. All players can see what it is.
Hoarding Dragon's last two abilities are linked. The third ability refers only to the card exiled by Hoarding Dragon's second ability. In other words, each Dragon has its own hoard.