fix last-file-only bug