Added functionality for detecting file extension.