fixed bug where excel data was corrupted if write function was called twice.