So I am writing a program which writes data into an opened excel file. 
The issue is that I need to run an infinite loop and the program is closed when it is killed. 
The file isn't even created when I do this. workbook.close() is outside the infinite while loop. 
Is there a flush method within xlsxwriter so that I can save the data?
Is there a flush method in the xlsxwriter module

No. You can only close()/save a file once with XlsxWriter.
Is there a flush method in the xlsxwriter module? [Python 2.7]