fixing issue where the output logging breaks during directory listing