finish output into .txt