Fixed off-by-one error that would print the last line twice.