Finally adding the main program to read and write, input and output respectively
Refactoring a bit