textscan is always relative to the current position in the file. You can use fseek to rewind to the beginning of the file.
Positioning by line number is very inefficient. However if you are going to process a file multiple times then it can be effective to build an index of line numbers and corresponding offsets in the file which ftell can tell you.