diff --git a/src/uu/split/src/split.rs b/src/uu/split/src/split.rs index c40a6a07ef0..fcab096e2e0 100644 --- a/src/uu/split/src/split.rs +++ b/src/uu/split/src/split.rs @@ -1028,14 +1028,16 @@ impl ManageOutFiles for OutFiles { // Could have hit system limit for open files. // Try to close one previously instantiated writer first for (i, out_file) in self.iter_mut().enumerate() { - if i != idx && out_file.maybe_writer.is_some() { - out_file.maybe_writer.as_mut().unwrap().flush()?; - out_file.maybe_writer = None; - out_file.is_new = false; - count += 1; - - // And then try to instantiate the writer again - continue 'loop1; + if i != idx { + if let Some(writer) = out_file.maybe_writer.as_mut() { + writer.flush()?; + out_file.maybe_writer = None; + out_file.is_new = false; + count += 1; + + // And then try to instantiate the writer again + continue 'loop1; + } } }