Fixed mistake where directory iterator should have been used to list directory contents