while True: self.logger.info("[Re]starting to read %s" % self.input_file) with open(self.input_file, "rb") as f: f1 = open (fname, "w") # The dummy writer has to be opened after a reader, otherwise it would block for line in f: ...do_stuff_with_line...(line)