Welcome again
Don't use += on Strings inside a loop because you may get poor performance. Add your lines to a List or append them to a StringBuilder
Don't use System.exit. If you have problems, throw an Exception instead. System.exit is potentially harmful in a multi‑threaded environment because it can stop the JVM while some tasks are only partially done.
There is another serious error: you are not closing the file.
You should do that by means of
try with resources. Otherwise there is a risk of your file being locked forever.
Don't
test for inputFile != null. You cannot have inputFile equal to
null, so you can delete that part.
Why are you using a
char[]? That is low‑level code, which you should avoid in a high‑level language. Where did you get the numbers 32 and 126 from? Remind yourself of the
range of ASCII which goes 0...127 (=7f). You obviously wanted ASCII minus the control characters and “del”. There is a slight hazard to doing that; if you write your file on a Windows® box, it will use \r\n as line end (=0x000d0x0000a in hexadecimal), but if you read that file on a Mac or Linux box, that will use \n as line end, so there is a risk that the \r characters will be read using nextLine() and will cause a spurious error.
There is no need for casts since
chars are not letters but numbers. Don't write the decimal numbers. Write
if (letters[i] < ' ' || letters[i] > '~')...
Don't wait until you have read the whole file before you test for wrong characters. Do it inside the loop, so you can stop reading before you have gone through the whole file. You can also give some hint where the error occurs:-
Anyway. there is bound to be a better way to do it. One way to do it is to create a
regular expression (=regex) which represents ASCII characters minus control characters, but including line end, tab, etc. There is
a method in the String class which tests whether it matches a regex.