The code presented is not complete … should have just followed what was on the other fields to ensure the string value was saved back…
void StringToPrint()
{
string currentStringToPrint = serializedObject.FindProperty("stringToPrint").stringValue;
string requiredStringToPrint = EditorGUILayout.TextField("String to print", currentStringToPrint);
if (currentStringToPrint != requiredStringToPrint)
{
serializedObject.FindProperty("stringToPrint").stringValue = requiredStringToPrint;
}
}