import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;

public class Conversion {
    public static void main(String[] args) {
        try (BufferedReader br = new BufferedReader(new FileReader(args[0]))) {
            String fullContent = "";
            String htmlContent = "";

            {
                int i = 0;
                boolean canRead = true;
                while (canRead) {
                    String content = br.readLine();
                    if (content != null) {
                        if (i == 0) {
                            fullContent += content;
                        } else {
                            fullContent += "<br>" + content;
                        }
                        i++;
                    } else canRead = false;
                }
            }

            System.out.println(fullContent);

            br.close();

            try (BufferedReader br2 = new BufferedReader(new FileReader("base.html"))) {
                htmlContent = br2.readLine();
                br2.close();
            } catch (Exception e) {

            }

            htmlContent = htmlContent.replaceAll("TOREPLACE", fullContent);
            System.out.println(htmlContent);

            try (BufferedWriter bw = new BufferedWriter(new FileWriter(args[0] + ".html"))) {
                bw.write(htmlContent);
                bw.close();
            } catch (IOException e) {

            }
        } catch (IOException e) {

        }
    }
}
