writing to text file failed