Wouldn't it be easier to use:
int bytesRead;
if (Serial.available()) { // when the serial port is available
bytesRead = Serial.ReadBytesUntil('\n', command, MAXLEN);
// more code...
This reads the entire line of code up to the newline character into the string buffer command and returns the number of characters that were read.