Fixed input and output of files on sockets