Is it possible to extract a particular line from a file knowing its line number? For example, just get the contents of line N as a string from file "text.txt"?
N
You could get it by index from readlines.
readlines
line = IO.readlines("file.txt")[42]
Only use this if it's a small file.
2.1m questions
2.1m answers
60 comments
57.0k users