Fixed the checking of what the filename ends with.