Check for module before running a file (fixes #312)

This fixes #312.


Thanks.