Fixed crash

I think the problem was either with the file name string or the fact
that it wasn't getting flushed.