added outputfile option (default to stdout)