Problems with importing a document and changing the strings of the document and outputting the new strings in a new .txt document
<p>It should then output a new .txt document, but when it does, it outputs the original document. I get the error message: </p>

<pre><code>Exception in thread "main" java.lang.Error: Unresolved compilation problem: 
    This method must return a result of type String
</code></pre>

<p>If I comment out the return "ok", but otherwise it creates a new document with the same details as the original document. </p>

<p>What could be the cause? </p>

<pre><code>public static String Replace(String filename) {
    try {
        Scanner file = new Scanner(new File(filename));
        System.out.println(file);
        StringBuilder b = new StringBuilder();
        String s = "";
        while(file.hasNextLine()){

            s = file.nextLine();


            if (s.equals("X")) {
                s = "0";
                b.append(s).append(System.getProperty("line.separator"));
            } else {
                b.append(s).append(System.getProperty("line.separator"));
            }

        }
        try (PrintStream out = new PrintStream(new FileOutputStream("test1,1.txt"))) {
            out.print(b);
            out.close();
        } catch (IOException e) {

        }

    } catch (Exception e) {
        System.out.println("Problem reading file.");
    }
    return "ok";
}
</code></pre>