Added nl for numbering lines, switched some to use stdout