added error check for readdir no flags