File manipuation and basic generation algorithm.