You can't, I catch an attempt to open an already open file and return an error to catch this bug.
SD.h can't do that due to the poor API design.
Here is an SdFat example:
if (!sd.begin(chipSelect, SPI_HALF_SPEED)) sd.initErrorHalt();
if (!myFile.open("test.txt", O_RDWR | O_CREAT | O_AT_END)) {
sd.errorHalt("opening test.txt first time failed");
}
if (!myFile.open("test.txt", O_RDWR | O_CREAT | O_AT_END)) {
sd.errorHalt("opening test.txt second time failed");
it prints:
error: opening test.txt second time failed