Modified the code to set the output file to be stdout if there is no input file