Added support for specifying output file name and for overwriting the existing output file.