Fix syncing problem
Wrong end file condition