in reply to question regarding slices

I'd check out grep and/or the file test operators before proceeding with filter solution that you propose. Slicing may work, but it's a bit of an off-handed way of doing it.

The file test operators (-e, -s, etc..) should let you select the canidate files that are actually readable or that have readable content.

Doing a grep on your readdir should let you select the files with names/extensions that you want to read. You can even combine the filetests with a grep.

Hanlon's Razor - "Never attribute to malice that which can be adequately explained by stupidity"