Changed file loop to async to catch done loop condition