Fixed quick logging on same file

If you log quickly in succession, it will cause and error because the
streams are not closed quickly enough. This has been fixed.