You're missing a break
in the if
statement on line 57. Compare what you have with the example given previously. Without the break
the while
loop will continue to execute until it reaches the end of the file -- not what you want!
Also, you still require some code to move from the line where the target scan is found (that is, the line with '#S' on it) to the start of the data. This should go between the end of the part where you look for the correct scan (line 64) and the start of the bit where you start to read the data (line 67). This is also previously mentioned in this thread (see here).