throws exception if the file is of the incorrect type. see @todo