Thank you both for your prompt reply.
I had been staring at the code for a while but didn't see the typo in my code. Seemed that in the real code an empty last line of the data.txt also gave some problem. I'll find my way out of that (tomorrow, as it's too late here by now)
And yes, I'll continue to use strict and warnings!