Because there is only one variable called keyword that closes. However, the temporary variable is different from each iteration.
Thus, without a temporary variable, when lambda is executed later, keyword evaluates the last value that was assigned in the loop.
Another solution, in some cases, is a forced evaluation (and ends with a List or such).
user166390
source share