I grit my teeth every time I see code with the opening brace appended to the preceding line. Particularly when, as here, it's not done consistently.
One of the biggest problems novices face is understanding the control structure of there code and especially seeing where it is not what they intended. Putting each matching pair of { and } on separate lines indented by the same amount makes this much easier to check visually.