user76158: I am reading sd card .txt file, I want to read the first line then how to save the position of the pointer for the next line read?

user68973: File myFile = SD.open("test.txt", O_RDWR);
if (myFile) {
  
  while (myFile.available()) {
    int i = 0;
    while (i < myFile.size()) { 
      inputString =  myFile.readStringUntil('\n');      
      //Serial.print(inputString);
      if (myFile.readStringUntil('\n')) {

I have set a size for the loop, every time it returns "I want it to read a new line" but it skips, what could be the reason?
To help with this question, I wanted to show the process I did on the same question. Thank you, I will ask the question elsewhere.
I am sending from the serial port when the end of the line is not read twice, during each reading. I'm sending line by line

user4143: You should not need to save the position, the file knows where you last read from. You'd only need to manually save such information if you close the file and re-open it again, which unless you have a good reason is actually a very wasteful operation.
If you really do need to you can use the .position() and .seek() functions:
Save the location:
uint32_t pos = myFile.position();

Recall the location:
myFile.seek(pos);

Documentation:

https://www.arduino.cc/en/Reference/FilePosition
https://www.arduino.cc/en/Reference/FileSeek


76158: <p>I am reading sd card .txt file, I want to read the first line then how to save the position of the pointer for the next line read?</p>
 68973: <p>File myFile = SD.open(&quot;test.txt&quot;, O_RDWR);</p>
<pre><code>if (myFile) {
  
  while (myFile.available()) {
    int i = 0;
    while (i &lt; myFile.size()) { 
      inputString =  myFile.readStringUntil('\n');      
      //Serial.print(inputString);
      if (myFile.readStringUntil('\n')) {
</code></pre>
<p>I have set a size for the loop, every time it returns &quot;I want it to read a new line&quot; but it skips, what could be the reason?</p>
<p>To help with this question, I wanted to show the process I did on the same question. Thank you, I will ask the question elsewhere.
I am sending from the serial port when the end of the line is not read twice, during each reading. I'm sending line by line</p>
 4143: <p>You should not need to save the position, the file knows where you last read from. You'd only need to manually save such information if you close the file and re-open it again, which unless you have a good reason is actually a very wasteful operation.</p>
<p>If you really <em>do</em> need to you can use the <code>.position()</code> and <code>.seek()</code> functions:</p>
<p>Save the location:</p>
<pre class="lang-cpp prettyprint-override"><code>uint32_t pos = myFile.position();
</code></pre>
<p>Recall the location:</p>
<pre class="lang-cpp prettyprint-override"><code>myFile.seek(pos);
</code></pre>
<p>Documentation:</p>
<ul>
<li><a href="https://www.arduino.cc/en/Reference/FilePosition" rel="nofollow noreferrer">https://www.arduino.cc/en/Reference/FilePosition</a></li>
<li><a href="https://www.arduino.cc/en/Reference/FileSeek" rel="nofollow noreferrer">https://www.arduino.cc/en/Reference/FileSeek</a></li>
</ul>
