def detect_trailing_columns(file, sep, heading_columns):
    """ Tests first 10 lines to see if there are empty trailing columns"""
    file.seek(0)
    return_int = float('Inf')
    for i in range(10):
        line = file.readline()
        return_int = min(return_int, len(line.replace('\n', '')) - len(line
            .replace('\n', '').strip(sep)) - heading_columns)
        if return_int == 0:
            return 0
    return return_int
