Take into account comments from @graphicore

Don't use for...in for array iteration

Don't store return value of project.open, as it's the same each time for the
same project.

Don't expect the code to work yet as a result of these changes!