Guys I take this double writing problem wherever I use Serial.read(), I have searched in forum and some people gets this problem too. I know code has no logical errors, even I copy pasted one code in forum and same result.
When you have the line ending menu set to newline, it sends the data you entered (B in this case), followed by a newline character. Do you see the problem now?
The possible solutions:
Set the line ending menu to "No line ending".
Change your code so it works as you want it to with any line ending characters.