minor: Convert while into for-next enchanced