check if sorted file was created. Fix error reporting