def read_xsc_step_number(xsc_filename):
    """
    Read a NAMD .xsc file to extract the latest step to use as input
    for restarts and such.
    """
    
    last_step = 0
    with open(xsc_filename, "r") as f:
        for line in f.readlines():
            if line.startswith("#"):
                continue
            last_step = int(line.strip().split(" ")[0])
    
    return last_step