Fixed incorrect brackets and corrected method of checking invalid filename.