Fixed: writer.close() was missing.