use collectFirst instand of a var and iterate

But if listFilesSafely return a lazy list, the current code doest not work too. the scala for comprehension is only a sugar, it is same as `map` if there is one iterator.
so 
`
for (child <- listFilesSafely(file)) {
            try {
              deleteRecursively(child)
            } catch {
              // In case of multiple exceptions, only last one will be thrown
              case ioe: IOException => savedIOException = ioe
            }
          }
`
is the same as 
`
listFilesSafely(file).map{child =>
            try {
              deleteRecursively(child)
            } catch {
              // In case of multiple exceptions, only last one will be thrown
              case ioe: IOException => savedIOException = ioe
            }
          }
`
the `savedIOException` always be null.