private void verifyLinesInFile(Path filePath, int numLines, boolean verifyLinearity) throws Exception {
        try (BufferedReader reader = new BufferedReader(new InputStreamReader(Files.newInputStream(filePath)))) {
            AtomicInteger i = new AtomicInteger(0);
            TestUtils.waitForCondition(() -> {
                reader.lines().forEach(line -> {
                    if (verifyLinearity) {
                        assertEquals(MESSAGE_PREFIX + i, line);
                    } else {
                        assertTrue(line.startsWith(MESSAGE_PREFIX));
                    }
                    i.getAndIncrement();
                });

                return i.get() >= numLines;
            }, "Expected to read " + numLines + " lines from the file");
        }

        // Ensure that there are exactly the expected number of lines present
        assertEquals(numLines, Files.readAllLines(filePath).size());
    }
Verify that the number of lines in the file at {@code filePath} is equal to {@code numLines} and that they all begin with the
prefix {@link #MESSAGE_PREFIX}.
<p>
If {@code verifyLinearity} is true, this method will also verify that the lines have a linearly increasing message number
(beginning with 0) after the prefix.

@param filePath the file path
@param numLines the expected number of lines in the file
@param verifyLinearity true if the line contents are to be verified
connect/file/src/test/java/org/apache/kafka/connect/file/integration/FileStreamSinkConnectorIntegrationTest.java