diff --git a/README.md b/README.md
index d13c811e9f700164010bd2d400ebb1376a68cc9f..0f36460ff58aedd4ed3daccf5b726938ea571ba2 100644
--- a/README.md
+++ b/README.md
@@ -6,7 +6,5 @@ The spec for this project can be found at [grep.md](https://gitlab.caltech.edu/c
 
 ## Testing infrastructure
 
-Your submission will be run against the tests in the `tests` directory.
-If your submission passes all the tests and you have not intentionally written your program to defeat the test cases, you will receive full credit on the project.
-
-To run the tests, you need to run `npm install` once and then `npm test` each time you want to run the tests.
+Several tests are provided in the `tests` directory.
+To run them, you need to run `npm install` once and then `npm test` each time you want to run the tests.
diff --git a/tests/test.js b/tests/test.js
index e91972941a7132e0bc447e4af8d23a6846d1f094..f652fd9caa7073e8fd2174fa923d96461ad8db9b 100644
--- a/tests/test.js
+++ b/tests/test.js
@@ -1,6 +1,6 @@
 const fs = require('fs')
 const test = require('ava')
-const {execFilePromise, matchOutput, reorderings, toLines} = require('./util')
+const {execFilePromise, matchOutput, reorderings} = require('./util')
 
 process.chdir(__dirname)
 
@@ -558,7 +558,7 @@ for (const {args, expected} of TESTS) {
   for (const args of reorderings(parameters, flags)) {
     test(`grep ${args.join(' ')}`, async t => {
       const {stdout} = await execFilePromise('node', ['../grep.js', ...args])
-      matchOutput(t, toLines(stdout), expected)
+      matchOutput(t, stdout, expected)
     })
   }
 }
@@ -569,8 +569,8 @@ test('grep no matches', async t => {
   try {
     ({stdout} = await execFilePromise('node', ['../grep.js', 'no-such-string', 'files/independence.txt']))
   }
-  catch (e) { stdout = e.stdout }
-  t.deepEqual(stdout, '')
+  catch (e) { ({stdout} = e) }
+  matchOutput(t, stdout, [])
 })
 
 // Test grepping the standard input
@@ -581,7 +581,7 @@ test('grep stdin', async t => {
     .pipe(grepPromise.child.stdin)
     .on('error', _ => t.fail('grep.js did not read stdin'))
   const {stdout} = await grepPromise
-  t.deepEqual(toLines(stdout), [
+  matchOutput(t, stdout, [[
     '# The Rust Programming Language',
     '[The Rust Programming Language](title-page.md)',
     '## Basic Rust Literacy',
@@ -589,7 +589,7 @@ test('grep stdin', async t => {
     '- [Object Oriented Programming Features of Rust](ch17-00-oop.md)',
     '    - [Unsafe Rust](ch19-01-unsafe-rust.md)',
     '    - [G - How Rust is Made and “Nightly Rust”](appendix-07-nightly-rust.md)'
-  ])
+  ]])
 })
 
 // Ensure that the streams deal with lines spread across chunks correctly
@@ -598,6 +598,7 @@ test('multiple chunk input file', async t => {
   for (let i = 0; i < 10; i++) {
     const search = `${i}`
     const {stdout} = await execFilePromise('node', ['../grep.js', search, 'files/long.txt'])
-    t.deepEqual(toLines(stdout), lines.filter(line => line.includes(search)))
+    const expectedLines = lines.filter(line => line.includes(search))
+    t.deepEqual(stdout, expectedLines.map(line => `${line}\n`).join(''))
   }
 })
diff --git a/tests/util.js b/tests/util.js
index b89dd2445d7bcc2ea79496e9b2f40b2d20483401..b24a8b8b5d60fa1140e25b85f23035616b13a203 100644
--- a/tests/util.js
+++ b/tests/util.js
@@ -3,12 +3,6 @@ const {promisify} = require('util')
 
 exports.execFilePromise = promisify(execFile)
 
-exports.toLines = text => {
-  const lines = text.split('\n')
-  if (lines.length && !lines[lines.length - 1].length) lines.pop()
-  return lines
-}
-
 function* reorderings(fixed, reorderable) {
   if (!reorderable.length) {
     yield fixed
@@ -22,6 +16,12 @@ function* reorderings(fixed, reorderable) {
 }
 exports.reorderings = reorderings
 
+function toLines(text) {
+  const lines = text.split('\n')
+  if (lines.length && !lines[lines.length - 1]) lines.pop()
+  return lines
+}
+
 /**
  * Checks that grep.js's output matches an array of expected outputs for each file.
  * Each file's lines must appear in order,
@@ -42,7 +42,7 @@ exports.matchOutput = (t, actual, expected) => {
 
   for (const expectedLines of expected) addNextLine(new Set(expectedLines))
   const expectedOutput = []
-  for (const line of actual) {
+  for (const line of toLines(actual)) {
     const expectedRest = nextLines.get(line)
     // If this was not the next line in any file, skip it
     if (!expectedRest) continue
@@ -57,5 +57,9 @@ exports.matchOutput = (t, actual, expected) => {
   for (const [firstLine, remainingLines] of nextLines) {
     expectedOutput.push(firstLine, ...remainingLines)
   }
-  t.deepEqual(actual, expectedOutput, 'Unexpected grep.js output')
+  t.deepEqual(
+    actual,
+    expectedOutput.map(line => `${line}\n`).join(''),
+    'Unexpected grep.js output'
+  )
 }