What you want to do is build a text-based database server.
Sounds to me like inventing the wheel all over again.
If you want to go through with it, I suggest you change your approach a little.
The last thing you want is to have to read every question and answer in the file just because you have to change the last question.
So, change the format of your file to make every question line the same length and every answer line the same length.
That way, every question/answer block is the same size in bytes.
Then if you want to read the second question, you can open the file and use fseek() to move directly to the second question in the file, without reading the first question.
Using this method you can read or write any question or answer in the file without having to go trough every line in the file.
Now you can skip from question to question, reading just the questions, not the answers.
Put the questions into a select box, and make the value equal the the question number.
0 for the first, 1 for the second etc.
On submission, pass the question id to the edit script.
Skip "question_id" questions and read the question and answers.
After editing, open the file again for read/write, skip "question_id" questions, and write the new question data.
That should leave all the other questions in tact, while you only have to write the data for one question, not all questions.
HIH