Replace contents of a file with output from a program