Use toString instead of writeToString (#4563)