I think this is just a representation in your IDE or terminal environment.  Try something like the following, then open the file and see for yourself if its writing in its entirety:
x = 'abcd'*10000
with open('test.txt', 'w+') as fh:
    fh.write(x)
Note the the above will write a file to whatever your current working directory is.  You may first want to navigate to your ~/Desktop before calling Python.
Also, how are you building the string a?  How is textfile being written?  If the call to textfile.write(a) is occurring within a loop, there may be a bug in the loop.  (Showing more of your code would help)