Fixed a bug in filename detection.