<commit_before>package com.ibm.database.compatibility;

import java.io.BufferedWriter;
import java.io.Closeable;
import java.io.File;
import java.io.FileWriter;
import java.io.Flushable;
import java.io.IOException;
import java.io.Writer;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;

public class JsonOperationWriter implements OperationWriter, Flushable, Closeable {
	
	private final Writer writer;
	private final BufferedWriter bufferedWriter;
	
	public JsonOperationWriter(String pathToFile) throws IOException {
		this(new FileWriter(pathToFile));
	}

	public JsonOperationWriter(File file) throws IOException {
		this(new FileWriter(file));
	}

	public JsonOperationWriter(Writer writer) {
		this.writer = writer;
		this.bufferedWriter = new BufferedWriter(writer);
	}
	
	@Override
	public void write(Operation op) throws IOException {
		bufferedWriter.write(GsonUtils.newGson().toJson(op));
	}

	@Override
	public void writeComment(String comment) throws IOException {
		String[] lines = comment.split("\n");
		for (String line : lines) {
			bufferedWriter.write("# ");
			bufferedWriter.write(line);			
		}
	}<commit_msg>Add newline output when using the JsonOperationWriter.<commit_after>package com.ibm.database.compatibility;

import java.io.BufferedWriter;
import java.io.Closeable;
import java.io.File;
import java.io.FileWriter;
import java.io.Flushable;
import java.io.IOException;
import java.io.Writer;

public class JsonOperationWriter implements OperationWriter, Flushable, Closeable {
	
	private final Writer writer;
	private final BufferedWriter bufferedWriter;
	
	public JsonOperationWriter(String pathToFile) throws IOException {
		this(new FileWriter(pathToFile));
	}

	public JsonOperationWriter(File file) throws IOException {
		this(new FileWriter(file));
	}

	public JsonOperationWriter(Writer writer) {
		this.writer = writer;
		this.bufferedWriter = new BufferedWriter(writer);
	}
	
	@Override
	public void write(Operation op) throws IOException {
		bufferedWriter.write(GsonUtils.newGson().toJson(op));
		bufferedWriter.newLine();
	}

	@Override
	public void writeComment(String comment) throws IOException {
		String[] lines = comment.split("\n");
		for (String line : lines) {
			bufferedWriter.write("# ");
			bufferedWriter.write(line);
			bufferedWriter.newLine();
		}
	}
{'fraction_non_alphanumeric': 0.10098839707778255, 'fraction_numerical': 0.0, 'mean_word_length': 5.3780821917808215, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '683584', 'n_tokens_mistral': 732, 'n_tokens_neox': 671, 'n_words': 166}