Fixed bug in extracting file extension