Refs #9043 Solved EOL problem and fixed an out of bounds error

The EOL problem seems to have been solved by str.splitlines()

Made a mistake when optimizing the checks, it caused and out of bounds error. Solved by merging it with the next check and putting it at the end so that it's the last check to be done