fixed file endswith bug