5
$\begingroup$

What happened with this file?

infile = "\\test data.txt";  

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

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

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

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 :

$\endgroup$

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.