Think of it like a telephone call. You, the client, make a call to a service provider, the server. Once you have established the connection you ask questions of the service provider and it provides answers. And sometimes the service provider will ask questions and the client will provide the answers. The only issue is that you speak the same language and understand what information is to be provided and in what form.
A typical sequence would be something like:
Client: connect to server
Server sends message: Please enter your userid:
Client sends message: user01
Server sends message: Please enter your password:
Client sends message: passwd01
Server verifies userid and password
If valid
Send message: welcome to the server, please enter your command.
Else
Send message: invalid credentials, access denied.
Server closes connection.
Endif
... etc.
It is not clear where this text file will exist, on the server or the client, so you need to make that clear. Whichever it is, it is easy for that application piece to create the file from information passed through the socket.
[edit]
Java Network Programming FAQ[
^]
Lesson: All About Sockets[
^]
[/edit]