Improved format checking to fix the bug dealing with file without extension.