USACO Bronze-Censoring Bug

Hi USACO Forum,
Whenever I submit my code for the problem Bronze 2015 Problem Censoring the grader tells me the following:

Incorrect answer on sample input case – details below
Your output file censor.out:

The correct answer:
whatthefun

Your program wrote this on standard output:
whatthefun

I was wondering as to why I am getting these errors and what I could do to prevent these in the future.

My code is below



import java.io.*;
import java.util.*;

public class Main {
	public static void main(String[] args) throws IOException {
			Kattio io = new Kattio("censor");
			String S = io.next();
			String censor = io.next();
			boolean containscensor = S.contains(censor);
			while (S.contains(censor)) {
				S = S.replace(censor, "");
	}
			System.out.println(S);
}
}





class Kattio extends PrintWriter {
	private BufferedReader r;
	private StringTokenizer st;

	// standard input
	public Kattio() {
		this(System.in, System.out);
	}

	public Kattio(InputStream i, OutputStream o) {
		super(o);
		r = new BufferedReader(new InputStreamReader(i));
	}

	// USACO-style file input
	public Kattio(String problemName) throws IOException {
		super(problemName + ".out");
		r = new BufferedReader(new FileReader(problemName + ".in"));
	}

	// returns null if no more input
	public String next() {
		try {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(r.readLine());
			return st.nextToken();
		} catch (Exception e) {
		}
		return null;
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}

	public long nextLong() {
		return Long.parseLong(next());
	}
}

Thanks!

Do you have spaces at the end of your output?

No I don’t believe there are any

What error did you get? Can you attach a screenshot?