@GaG No it wasn't the issue, else is not in parenthesis so it's gonna execute anyway. I know that's not the ideal code :P
P.S- the above guy's solution worked.
I want to make a simple condition, that if connection was completed succesfully, then do next block, otherwise take another credentials from the file and check. I'm a bit confused how to achieve that. Is it possible to get a general success result from each block and use it as a condition, or should I do it some other way?