Stylistically this is nicer but you're ending up doing a write on each loop, which is more expensive than a read.