a poor workaround for threading mishaps. thread closes the file, operating system says ok, main loop realizes that the file is not written on the disk yet... I know there is a better way of doing this.