public static synchronized User addUser(String username,
			ArrayList<User> users) {
		users = DataReader.getUsers();
		// check if the user exists
		for (User u : users) {
			if (u.getUsername().equalsIgnoreCase(username)) {
				System.out.println("User already exists");
				return u;
			}
		}

		// add the user to the user arraylist
		User u = new User();
		u.setBalance(1000);
		u.setUsername(username);
		u.setUserStock(null);
		users.add(u);

		// write to the users file
		File f = new File("users.txt");
		FileWriter fr = null;
		try {
			fr = new FileWriter(f);
			BufferedWriter br = new BufferedWriter(fr);
			String s = "";

			for (User e : users) {
				s += e.getUsername() + " " + e.getBalance();
				s += "\n";
			}
			br.write(s);
			br.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
		return u;
	}