Consider the following two sentences:
If you do not study, you will fail the exam.
If you do not study, then you will fail the exam.
I know that the first sentence is preferred over the second one. The word "then" is a redundant word in the second sentence. But my question is: does that make the second sentence grammatically incorrect?