Defensive Programming

Added defensive section to the inputted text files. rejects clearly
invalid files.