\Header{readLines}{Read Text Lines from a Connection}
\keyword{file}{readLines}
\keyword{connection}{readLines}
\begin{Description}\relax
Read text lines from a connection.\end{Description}
\begin{Usage}
\begin{verbatim}
readLines(con = stdin(), n = -1, ok = TRUE)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{con}] A connection object or a character string.
\item[\code{n}] integer.  The (maximal) number of lines to
read. Negative values indicate that one should read up to the end of
the connection.
\item[\code{ok}] logical. Is it OK to reach the end of the connection before
\code{n > 0} lines are read? If not, an error will be generated.
\end{ldescription}
\end{Arguments}
\begin{Details}\relax
If the \code{con} is a character string, the functions call
\code{\Link{file}} to obtain an file connection which is opened for
the duration of the function call.

If the connection is open it is read from its current position.
If it is not open, it is opened for the duration of the call and then
closed again.

An incomplete last line (no final newline) will be accepted, with a warning.\end{Details}
\begin{Value}
A character vector of length the number of lines read.\end{Value}
\begin{SeeAlso}\relax
\code{\Link{connection}}, \code{\Link{writeLines}},
\code{\Link{scan}}\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
cat("TITLE extra line", "2 3 5 7", "", "11 13 17", file="ex.data",
    sep="\n")
readLines("ex.data", n=-1)
unlink("ex.data") # tidy up
\end{ExampleCode}
\end{Examples}

