Save data in text file format

Save the data in text file format. Has one bug: does not save newline
character. Will come back to it later.