Need to fix - attempting to write to text file