diff --git a/src/calibre/ebooks/rtf2xml/combine_borders.py b/src/calibre/ebooks/rtf2xml/combine_borders.py index c0b7185c9b..a0bc77e7ad 100755 --- a/src/calibre/ebooks/rtf2xml/combine_borders.py +++ b/src/calibre/ebooks/rtf2xml/combine_borders.py @@ -78,7 +78,7 @@ class CombineBorders: self.add_to_border_desc(line) def combine_borders(self): - with open(self.__file, 'r') as read_obj, + with open(self.__file, 'r') as read_obj, \ open(self.__write_to, 'w') as write_obj: for line in read_obj: self.__first_five = line[0:5] diff --git a/src/calibre/ebooks/rtf2xml/footnote.py b/src/calibre/ebooks/rtf2xml/footnote.py index 0027348cde..c1ffb18ada 100755 --- a/src/calibre/ebooks/rtf2xml/footnote.py +++ b/src/calibre/ebooks/rtf2xml/footnote.py @@ -119,14 +119,11 @@ class Footnote: bottom of the main file. """ self.__initiate_sep_values() - self.__write_obj = open(self.__write_to, 'w') - with open(self.__file) as read_obj: - self.__footnote_holder = tempfile.mktemp() - self.__write_to_foot_obj = open(self.__footnote_holder, 'w') - line_to_read = 1 - while line_to_read: - line_to_read = read_obj.readline() - line = line_to_read + self.__footnote_holder = tempfile.mktemp() + with open(self.__file) as read_obj, \ + open(self.__write_to, 'w') as self.__write_obj, \ + open(self.__footnote_holder, 'w') as self.__write_to_foot_obj: + for line in read_obj: self.__token_info = line[:16] # keep track of opening and closing brackets if self.__token_info == 'ob