1.Added implementation for printing the output into an output file
1. altered the command line parameter handling for output files.
2. added some more comments.
added comments.