Added support to detect filename.