def truncae(self, pgno, maximumSize): buffer = [0]*maximumSize limit = 1024 count = 0 # opens the file for read and append f = open("F:/labOS/funner.dat", "r+") if f: # moves the pointer f.seek(pgno*1024+maximumSize) # instead of trimming the file it actually overwrites the file with empty spaces for i in range(limit): buffer[count] = " " f.write(str(buffer[count])) f.close()