deleting first line in SD card file

i would like to develop a program wherein test.txt composed of codes like :
jkla
jhks
yuha

i'd like to display it in LCD when the user insert a coin. and when the codes are shown,, i want to delete it from the file. Hope you can help me. Thank you

The only way to delete a line in a file is to copy the file to a new file, leaving out the line in question, then delete the old file.

could you please give me example on how i can do that. sorry i only have little knowledge in arduino. Thank you again :slight_smile:

Google “arduino copy sd card file” for examples.

Open two files at once, the original file for read and a new file for write. Read the first line from the read file and throw it away. Then loop to the end of the file, reading a line from the original file and writing it to the new file.

The same problem exists if you want to insert a line.

I asked the same question a while back and this was the only available solution.

adwsystems:
Open two files at once, the original file for read and a new file for write. Read the first line from the read file and throw it away. Then loop to the end of the file, reading a line from the original file and writing it to the new file.

The same problem exists if you want to insert a line.

I asked the same question a while back and this was the only available solution.

could you give me a example code? i really don't know how can where and how i can code it

Do try the google search.

i tried already, I already know how i can read data per line and display it in LCD. but i can’t find the logic how can i copy the original file without copying the line that i have display in the LCD.

The problem is definitely in the code you didn’t post.

daenerys28:
i tried already, I already know how i can read data per line and display it in LCD. but i can't find the logic how can i copy the original file without copying the line that i have display in the LCD.

There is no copy function. You know how to read. You know how to write. Read the first line from the read file and do nothing with it. Then begin a loop to the end of the file, reading a line from the original file and writing it to the new file.

Give it a try, post what doesn't work.