+filename = None
+
+(options, args) = getopt.getopt(sys.argv[1:], "f:", "file=")
+
+for option in options:
+ if option[0] == "-f" or option[0] == "--file":
+ filename = option[1]
+
+if not filename and len(args) > 0:
+ filename = args[0]
+
+if not filename:
+ sys.stderr.write("No crossword file specified, exiting.\n")
+ sys.exit(0)
+
+if os.path.exists(filename) and os.path.isfile(filename):
+ crossworddata = codecs.open(filename, "r", "utf-8").read()
+else:
+ sys.stderr.write("Couldn't open file %s\n" %(filename))
+ sys.exit(0)