Bugfix: file output may cause segfault on mac os.
Merge branch 'develop'