added .txt to the write function