MichaelL65:
char command[MAX_LEN]; // Set up the command buffer
static int c = 0; // Set up a counter (static so it does not get overwritten outside of this loop
Having a static index into a non-static array raises all sorts of red flags. Presumably you intended command to be static too.