also print to a file if possible.