What happened with this file?

infile = "\\test data.txt";  

outstr = OpenWrite[infile];
instr = OpenRead[infile];
Read[instr, Record];

All content of "test data.txt" was lost.

  • $\begingroup$ You should have used OpenAppend. $\endgroup$ – Mr.Wizard Mar 22 '13 at 16:52

From the help

OpenWrite["file"] open an output stream to a file, wiping out the previous contents of the file

... it's gone, you deleted it :


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.