Add fucntuon to write txt