changed the method to write to text