From 76b7418e3554aec45a364013ef6eb3d1052d11cf Mon Sep 17 00:00:00 2001 From: Reid Wagner Date: Sat, 9 Feb 2019 20:21:12 -0800 Subject: [PATCH] Only print contents if file wasn't empty, or EOF wasn't first thing received from stdin. --- src/controller.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/controller.rs b/src/controller.rs index 6f38a908..f91c0554 100644 --- a/src/controller.rs +++ b/src/controller.rs @@ -80,7 +80,9 @@ impl<'b> Controller<'b> { input_file: InputFile<'a>, ) -> Result<()> { printer.print_header(writer, input_file)?; - self.print_file_ranges(printer, writer, reader, &self.config.line_ranges)?; + if !reader.first_line.is_empty() { + self.print_file_ranges(printer, writer, reader, &self.config.line_ranges)?; + } printer.print_footer(writer)?; Ok(())