He would say goodbye if he were leaving.
Which of these sentences doesn't make sense?

A. "saying "goodbye", he walked out of the classroom and went home"
B. "saying "hello", he walked out of the classroom and went home"