I think the POS(ls_section, ls_line) was interchanged, should be POS(ls_line, ls_section).
One potential problem with this code is when there's a key that contains a value of '[' and ']'.
Ex.
Key1 = '[abcd]'
So, to be sure that it's a section and no longer a key, you should trim the ls_line and check the first and last character. If they are '[' and ']' respectively, then it's a section and not a key anymore.
Ex.
If Left(Trim(ls_line),1) ='[' and Right(Trim(ls_line),1) = ']' Then //This is another section.