More robust output file naming