Optimised to open and close file once, rather than each write.
Merge pull request #1223 from justinvelluppillai/master

Optimised to open and close file once, rather than each write.