@Override
	public WriteMsg write(FileContent data) throws RemoteException,
			IOException, NotBoundException {
		masterLogger.logMessage("===>> Write '" + data.fileName + "' request");
		if (!files.contains(data.fileName)) {

			// create new file and set meta data
			files.add(data.fileName);
			filePrimReplica.put(data.fileName, rand.nextInt(numReplicas));

			for (Iterator<Entry<Integer, ReplicaLoc>> iterator = replicaPaths
					.entrySet().iterator(); iterator.hasNext();) {
				Entry<Integer, ReplicaLoc> entry = iterator.next();
				ReplicaLoc repl = entry.getValue();
				String replLoc = repl.location;
				int replPort = repl.replicaPort;

				// Reading from replica
				Registry registryReplica1 = LocateRegistry.getRegistry(replLoc,
						replPort);
				ReplicaServerClientInterface replHandler = (ReplicaServerClientInterface) registryReplica1
						.lookup(Global.REPLICA_LOOKUP);
				replHandler.createFile(data.fileName);
			}
			// edit in filesDirectory.in
			try {
				PrintWriter out = new PrintWriter(new BufferedWriter(
						new FileWriter(Global.FILES_DIRECTORY, true)));
				out.print(data.fileName + "\n");
				out.close();
			} catch (Exception e) {
				System.err.println("Error in broadcast method: "
						+ e.getMessage());
			}
			// done
			masterLogger
					.logMessage("===>> Creating empty file in all replicas ....");
		}
		ReplicaLoc primLoc = replicaPaths.get(filePrimReplica
				.get(data.fileName));
		WriteMsg wMsg = new WriteMsg(txID++, 1, primLoc);

		return wMsg;
	}