Don't read the complete file in memory.
Module => Plugin.
Use UTIlity methods.
Use UTIs to tell script files.

It still won't work for files without extensions but now there's no need for an 'extension' list.