I'm trying to create a function that will search for a specific record and delete it, but my function is deleting all the contents of the file. I can't figure out which line in the code is incorrect. Please help!
Don't you think accessing the file directly could be complicated? You can put the content of the data file in some data structure, then process, before writing back to the file.
Also opening one file simultaneously is not a good idea. Finish with one, maybe inputting into your app, then call the close() method, before opening for output.