Added code to save text data to file