Hello, I would recommend using a Producer/Consumer architecture for this application. You should acquire your data in one while loop and write to file in a second, you can communicate between the two with a queue. You can find a template for this architecture under File>>New>>VI>>From Template>>Frameworks>>Design Patterns
I would also recommend a search on the forums for more info if needed.