I wrote a code that takes input data, writes it on a string then it is sent to a temp file that gets encrypted and the temp sends the encrypted file to the main file. Somehow I managed to make it work (only the register) but I didn't do anything to the code and now the data isn't written on the files. Any kind of help will be welcomed. Thanks!
#include<iostream>
#include<istream>
#include<fstream>
#include<stdlib.h>
#include<string.h>
#include<stdio.h>
using namespace std;
void login();
void reg();
void encrypt();
int main() {
    int rep;
    cout << "\t\t\t Welcome to Protek 0.1.\n" << "\t\t\t Do you already have a account?\n\n";
    cout << "\t\t\t\t 1 = YES    2 = NO\n";
    cin >> rep;
    
    switch (rep) {
        case 1:
        login();
        break;
        case 2:
        reg();
        break;
        default:
        break;
    }
 
}
void login() {
    int count;
    string LUserN, LUserP, LN, LP;
    system("cls");
    cout << "Please enter your name.";
    cin >> LUserN;
    cout << "Please enter your pass.";
    cin >> LUserP;
    ifstream input("data/pn.txt");
    while (input>>LN>>LP) {
        if (LN==LUserN && LP==LUserP) {
            count = 1;
     }
    }
    input.close();
    if (count == 1) {
        cout << "\t\t\t SUCCESS! \n";
        cin.get();
        cin.get();
        main();
    }
    else {
        cout << "\t\t\t ERROR";
        main();
    }
}
void reg() {
    string RUserN, RUserP;
    system("cls");
    cout << "\t\t\t Enter your username. \n";
    cin >> RUserN;
    cout << "\t\t\t Enter pass. \n";
    cin >> RUserP;
    encrypt();
    cout<< "\t\t\t Reg Complete!\n";
    main();
}
void encrypt() {
    char ch;
    fstream fps, fpt;
    fps.open("data/pn.txt", fstream::in);
    fpt.open("data/pt.txt", fstream::out);
    while (fps >> ch) {
        ch = ch * 22;
        fpt << ch;
    }
    fps.close();
    fpt.close();
    
 fps.open("data/pn.txt", fstream::out);
    fpt.open("data/pt.txt", fstream::in);
    while (fpt >> ch) 
        fps << ch;
        fpt.close();
        fps.close();
 
}
 
    