Hi Diego,
to speed things up, you should consider separating the TCP read and the file writing in two separate loops. For example, if you make two parallel loops: one that reads and adds data to a queue, and a second which reads the queue and writes to file, then you can read multiple datapoints at once and write less frequently to the file.
Investigate the use of a Producer-Consumer architecture.
I took the liberty of reorganizing your example to demonstrate the concept. I'd probably approach your task where your Python code is the client that publishes data and LabVIEW would act as a server (instead of the other way around), but I wanted to keep with the spirit of your example.
Client.vi