Possibly useful

In order to get it working I changed from .split to regex to make it a bit easier to parse. 
I remove the section where the first line is checked, because in my case part of the problem is that there was a single newline at the top of the file. Instead the first line that passes the regex is used.