I assume this is something along the lines of what you were looking for?
f = open('filename.txt', 'r') databaseRaw = f.read() database = databaseRaw.split('# Data Written') f.close() database.remove('') for i in range(0, len(database)) : database[i] = '# Data Written'+''.join(database[i]) for i in range(0, len(database)) : f = open("output.txt"+ str([i]) ,"w+") f.write(database[i]) f.close()
EDIT : Figured out the problem I had had before, works fine now.
it will create a new file per block, starting at 0, and if it creating a new line at the of end each file is an issue, I can make an easy way to remove it.