implement output to file.