I can enter if but not execute statements inside

Try printing ">" immediately before the String and "<" immediately after it. Use Serial.print() to print the string rather than Serial.println()

Any extra characters, typically a Linefeed or a space will be obvious