clean up the logic for deciding the output filename when using stdin