First, don't use DataInput/OutputStreams. They're for binary data I/O, not for text. Use FileReader together with BufferedReader (for input) and PrintWriter (for output.)
Second, the best way to write a big program is to write a small one and add to it a little at a time,
testing as you go. You've written a whole lot of code here which can't compile. You ought to start by getting just an empty class declaration to compile, and then an empty class including a main() to compile, and then have main print "hello, world" and run the program and make sure it works. Then try opening a file, reading a line, and printing it to System.out. Then you could open a second file for writing and putting the line into that file. Take small steps, and test each step along the way.
Third, write small methods. Don't write this whole program in main.