Trouble using string object in functions

I am trying to create a function, which searches for substrings in strings (simple stuff). For some reason, I can only get my code to work if I insert my substring into the function directly into the code with double quotes ". I am trying to use the serial to define the search critarion, but it won't find the substring if I do so. I have included the code and an image of the result down bellow:


FULL CODE:

// Variables used for string searching
String search;
String strSearched;
int strLength;
int index;

// Variables used for testing
String test;

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
}

void loop() {
  // put your main code here, to run repeatedly:
  while (Serial.available() == 0) { }
  Serial.println("INPUT WAS FOUND!");
  search = String(Serial.readString());
  checkSerial(search, "You searched in this sentence.");
  while (Serial.available()) {
    Serial.read();
  }
  Serial.println("----------------------------");
}

void checkSerial(String search, String strSearched) {
  int strAction = 0;
  Serial.print("Searched string: ");
  Serial.print(strSearched);
  Serial.println();
  Serial.print("You seached for: ");
  Serial.print(search);
  Serial.println();
  int index = strSearched.indexOf(search);
  if (index > -1) {
    Serial.print(search);
    Serial.print(" was found at ");
    Serial.print(index);
    Serial.print("'th place and removed.");
    Serial.println();
    strLength = search.length();
    strSearched.remove(index, strLength);
    Serial.print("The new string is now: ");
    Serial.print(strSearched);
    Serial.println();
    int strAction = 1;
  }
  else
  {
    Serial.println("The substring was not found :(");
  }
  return strAction;
}

RESULT:


The code works if I input the parameter manually into the function like this:

void loop() {
  // put your main code here, to run repeatedly:
  while (Serial.available() == 0) { }
  Serial.println("INPUT WAS FOUND!");
  search = String(Serial.readString());
  checkSerial("sentence", "You searched in this sentence.");
  while (Serial.available()) {
    Serial.read();
  }
  Serial.println("----------------------------");
}

Thank you for your time! It is my first post, so I hope I did it right.

Just don’t use the String class and go for c-string style,you’ll be more in control...

Read about the functions available in stdlib.h and string.h and use the Serial Input Basics tutorial to understand how to handle Serial input

This could also help: Planning and Implementing a Program

With this code, you really can't tell what the string to search for is:

  Serial.print("You seached for: ");
  Serial.print(search);
  Serial.println();

With this code, you could:

  Serial.print("You are looking for: [");
  Serial.print(search);
  Serial.println("]");

If you see:
You are looking for: [sentence
]
then, clearly, the string to look for contains non-printing characters.

If you see:
You are looking for: [sentence]
then, clearly, the string to look for does not contain any non-visible characters.

Which represents YOUR string to look for?