Encryption Program Problem

I have a question. I'm writing an encryption program.
Here's a snippet of the code that I can use to encrypt the files, but not to decrypt them. Could somebody take a look at them and see what they think is wrong?

------------Begin Code-----------------
while (!input.eof())
{ n=true;y=0;
while(!input.eof()){x=0;
if(n==true){extra[0]=0;}char temp[1];
n=false;
while (x<i)
{
if((int)pw[x]==1){
temp[0]=line[0]+x/pw[1]-pw[2]*pw[3]+pw[4]/pw[5]+pw[6]/pw[7]-pw[8]/pw[9]
+pw[10]/pw[11]-pw[12]*pw[13]-pw[14]*pw[15]-extra[0]*pw[0];extra[0]=line[0];
line[0]=temp[0];

/*temp[0]=line[0]/pw[0]+extra[0]/pw[15]+pw[14]/pw[13]+pw[12]*pw[11]-pw[10]*
pw[9]+pw[8]*pw[7]-pw[6]*pw[5]-pw[4]/pw[3]+pw[2]*pw[1]-x;
extra[0]=line[0];line[0]=temp[0];*/
}
x++;if (x==i){if (!input.eof()){output.write(line,sizeof(line));}}
continue;}
-------End of Code------------

Yes, I realize that, as of now, I can only use strings of one password character, but I need to solve the problem before I write more definitions.

Me