fix bug where initial lines were not being written

This commit is contained in:
Mike Cugini 2021-03-19 16:18:01 -04:00
parent a70a0828b6
commit 69a5ac4d51

View File

@ -94,7 +94,8 @@ fn try_main() -> Result<(), Box<dyn Error>> {
break;
}
let mut out_file = File::create(format!("{}{}", prefix, suffix))?;
for _ in 0..opts.lines {
out_file.write_all(line.as_bytes())?;
for _ in 1..opts.lines {
line.clear();
match reader.read_line(&mut line)? {
0 => {
@ -105,6 +106,7 @@ fn try_main() -> Result<(), Box<dyn Error>> {
}
};
}
line.clear();
}
// see if there's anything left for the remainder file