Second digitalWrite doesn't set to HIGH

I'm working on Elegoo's Lesson 5 Digital Inputs (with Mega 2560 The Most Complete Starter Kit). It worked fine and I decided to tweak it a little bit. I want the default LED (13) blink when I press any of the two buttons.

It works for buttonApin ("on" button), but for buttonBpin ("off" button) the LED's light is not bright but very subtle. Could you please help me to understand why it's happening?

Schema attached. The code is following:

int ledPin = 5;
int buttonApin = 9;
int buttonBpin = 8;

void setup() 
  pinMode(ledPin, OUTPUT);
  pinMode(buttonApin, INPUT_PULLUP);  
  pinMode(buttonBpin, INPUT_PULLUP);  
  pinMode(13, OUTPUT);

void loop() 
  digitalWrite(13, LOW);
  if (digitalRead(buttonApin) == LOW)
    digitalWrite(ledPin, HIGH);
    digitalWrite(13, HIGH);
  if (digitalRead(buttonBpin) == LOW)
    digitalWrite(ledPin, LOW);
    digitalWrite(13, HIGH); // this doesn't set LED to HIGH, but to something middle
    // digitalWrite(13, HIGH); // <-- uncommenting this line fixes the issue, LED is HIGH, but why...

Each time through loop() you unconditionally turn off the LED on pin 13. Is that deliberate ?

Hint: Loop executes very fast.

You are blinking the LED, but very fast. This is why it looks dim. UKHeliBob's post tells you where to look.

@UKHeliBob yes, it was deliberate since I need to turn LED off somewhere.

Thank you all! Now I understand that since the loop is looping very fast, there's no much time between the last digitalWrite(13, HIGH) and the next loop's digitalWrite(13, LOW). I will add a delay.

It's interesting that there IS enough time between the first digitalWrite(13, HIGH) and the next loop, probably because of additional if-statement which takes time.

it was deliberate since I need to turn LED off somewhere.

Please describe the conditions that must be true for you to want to turn off the LED on pin 13