open(INPUT, '>file2.dat'); binmode(INPUT); while (<$sock>) { print INPUT $_; } close INPUT;