You should compile your code and make sure it compiles at least so one doesn't have to chase problems like wrong naming.
I've fixed your code. See below.
C++
#include <fstream>
#include <iostream>
#include <string>
using namespace std;
int main()
{
fstream newfile("input.txt", ios::out);
if (newfile.is_open())
{
newfile << "The string is in the language.";
newfile.close();
}
newfile.open("input.txt", ios::in);
if (newfile.is_open())
{
string line;
while (getline(newfile, line))
cout << line;
newfile.close();
}
return 0;
}
Java
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Scanner;
public class Main
{
public static void main(String[] args)
{
File in = new File("input.txt");
File out = new File("output.txt");
try (Scanner scan = new Scanner(in);
PrintWriter pw = new PrintWriter(new FileWriter(out, true)))
{
while (scan.hasNext ())
pw.println(scan.next());
}
catch (IOException e)
{
e.printStackTrace();
System.exit(0);
}
}
}