I get an input file, which i read line wise and then convert each record from ascii to ebcdic format. After conversion, i have to write this to an output file. Then read the next record and do the same and print it in the next line.
Why do you need to print out the ebcdic file into a human readable ascii format? In your op your requirement is to convert the input file record by record into ebcdic lines which you have done. This is then then sent to IBM. IBM will presumably do any necessary conversions into readable formats if they need to.