I am assuming you are using bash as your shell.
You have two separate problems.
1. The (( )) construct is to perform arithmetic. To perform tests on values, you use the [[ ]] construct
2. You must be mindful of spaces inside your condition. There must be a space
between $? and your operator (-eq). There must also be a space between your last operand (1) and the end of the test condition (]])
fail=`echo $line | grep @`
if [[ $? -eq 1 ]]; then