Added option to specify output file