You did not say what did not work. One mistake I do see is that you are working on the third line, not the second (array indices start at zero).

Always use strict and warnings. If your file only has two lines this would have found the error. (I suspect that this is true because you should have recognized the first five characters of the third line)

Always check the status of open. If your script, as is, is unable to open the text file, you will not get any output.