This will return `None` if `line == ''`, and it doesn't appear that you account for that when you're using this function.