Two simple solutions that are guaranteed to work for anyone who is still looking:-
1)Increase the delay to 50 to 100 milliseconds.
2)Add this after the Serial.begin(9600) in setup;
Serial.setTimeout(50);
Increase the delay to 50 to 100 milliseconds.
Add this after the
Serial.begin(9600)
insetup()
;Serial.setTimeout(50);
Step two is the most important. It worked for me only after I added the above code. This is not mentioned very often in many other forums that I have looked when I had the exact same problem.