Fixed improperly closed buffered writer, fixes #9