Added better handling for input file.
Extended documentation