window: Use foreach rather than incrementing for to iterate over an array