Add checking for sorted files