## reading a 2GB bitstream file, already read in as f via chunking method. ## wpextract.log is a listing of the file header offset locations within the bitstream file ## wpfilesize.log is a listing of filesizes obtained from a struct.unpack method. ## Trying to create and write to a sequential list of files "on the fly" and extract data blocks that constitute WordPerfect files ## the out_block data is not being written to the series of empty .wp files, once created. Idle just hangs. g = open("images\\wpextract.log", "r") # reads header position file header_pos = g.readlines() h = open("images\\wpfilesize.log", "r") # reads in the list of file sizes for application in carve interation filesize_len = h.readlines() n=70 ##arbitrary figure - roughly 64 files, in truth for i in range(n): open('wpdocs\\file' + str(i) + '.wp', 'wb').close() root = "wpdocs" while f: for header in header_pos: f.seek(int(header), 0) for carved in filesize_len: out_block = f.read(int(carved)) while out_block: listing = os.listdir(root) out_block = f.read(int(carved)) for each_file in listing: path = os.path.join(root,each_file) doc_wp = open('path', 'wb') doc_wp.write("%s" % (out_block))