You are doing split multiple times to lines. Better way would be to to open the file in with statement, which garantees closing of the file automatically, split each line once to variable and do the slicing from there. If files are small your code is 'good enough'
Same way as you open a file and close it in the end, it is also good as OP to mark your thread solved after sharing the solution, as you did.
pyTony
pyMod
5,359 posts since Apr 2010
Reputation Points: 782
Solved Threads: 852