private static int writeLines(String fname, BufferedReader in) {
        try {
            byte[] buf = new byte[blockSize];
            int i = 0;
            for (;;) {
                String line = in.readLine();
                if (line == null || line.equals(".")) {
                    break;
                }
                for (int j = 0; j < line.length(); j++) {
                    if (i >= buf.length) {
                        byte[] newBuf = new byte[buf.length * 2];
                        System.arraycopy(buf, 0, newBuf, 0, buf.length);
                        buf = newBuf;
                    }
                    buf[i++] = (byte) line.charAt(j);
                }
                if (i >= buf.length) {
                    break;
                }
                buf[i++] = '\n';
            }
            return Library.write(fname, buf);
        } catch (IOException e) {
            e.printStackTrace();
            return -1;
        }
    } // writeLines(String, BufferedReader)