Behavior of map function

But why is the second invocation of a always giving zero while the first invocation always gives the correct answer?

Edit: I get it, it’s because readlines exhausts the file after first invocation -_-