From 8d124f92d6ea9ac262542507330b6d19b9a0421c Mon Sep 17 00:00:00 2001 From: John Schember Date: Sat, 21 Mar 2009 07:37:26 -0400 Subject: [PATCH] Only remove output file if it exists before writing to it in txt output --- src/calibre/ebooks/txt/writer.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/calibre/ebooks/txt/writer.py b/src/calibre/ebooks/txt/writer.py index 0fbf4a634c..84376ca2e7 100644 --- a/src/calibre/ebooks/txt/writer.py +++ b/src/calibre/ebooks/txt/writer.py @@ -53,7 +53,8 @@ class TXTWriter(object): for i in range(3 - end.count(self.newline)): tmpout = tmpout + self.newline - os.remove(path) + if os.path.exists(path): + os.remove(path) with open(path, 'w+b') as out: out.write(tmpout.encode('utf-8'))