- else if (!(fp = fopen(*argv, "w"))) {
- die(EXIT_FAILURE, "couldn't open `%s' for writing: %s",
- *argv, strerror(errno));
+ else {
+ outfile = *argv;
+ dstr_putf(&d, "%s.new", outfile);
+ if (!(fp = fopen(d.buf, "w"))) {
+ die(EXIT_FAILURE, "couldn't open `%s' for writing: %s",
+ d.buf, strerror(errno));
+ }