"So It is Written" is the 62nd episode of Inspector Gadget.
In North Africa, the kingdom there is very poor, but only a "chosen one" can lead them to treasure and dig it out. The Fierce Ones are guarding the treasure cave until the chosen one arrives. According to legend, the chosen one has fire and water in hands, is too tall to block the sun and can fly like a bird. The chosen one has to stay 3 days and nights in the treasure cave, so the treasure will fall out of the sky. Claw tells his agent posing as a journalist, Louise Lane, that Gadget can be a chosen one. Thanks to his gadgets (laser, water gun, legs, and 'copter), Gadget is thought by the kingdom to be a chosen one. Claw orders Lane to keep Gadget alive until he finds the treasure. Lane convinces Gadget that he is chosen for a trip to the Atlas mountains.
Gadget, Lane, and the Fierce Ones arrive at the mount where the treasure cave is. According to legend, the chosen one has to remove a stone from the entrance. Gadget thinks that the cave is a restaurant and it's an tourist attraction. The Fierce Ones find out that he's not the chosen one and they're about to burn Gadget down, but Penny and Brain decide to help him. Penny uses her computer book to cause a sandstorm while Brain saves Gadget. Lane destroys the stone and the Fierce Ones again think that Gadget is the chosen one. Gadget and Lane (followed by Brain) enter the cave and encounter some booby-traps, but they manage to stay alive and find the treasure chamber.
Meanwhile, Penny tries to find the another entrance to the cave, but she's caught by one of the Fierce Ones. Penny falls into a pitfall that turns out to be another entrance to the cave. Lane tells Gadget to go out and bring the Fierce Ones to the chamber because if the chosen one will leave the cave before the end of 3 days and nights, the Fierce Ones will kill him. Brain tries to keep Gadget in the cave, but he ends up pushing him out and getting him to trouble with the Fierce Ones.
The other M.A.D. agents arrive in a helicopter to help Lane load the treasure. Penny overrides the helicopter's systems, making it explode and the treasure fall out. The kingdom is no longer poor and Chief Quimby arrives to arrest the M.A.D. agents.