Moves main into its own file.
Marks function used in included file.
Removes unused includes.
Adds code to check if file not found.
Fixes off-by-one bug.
Lint fixes.