added logging and allow the output file to persist