Detect file name extensions more correctly
Don't dulicate dot in the file name