Added printDir function and loop.
tried to fix segmentation fault