import csv


def read_student_names(file):
    """If file ends in .csv, read the CSV file where each username should
    reside in the second column and the first column contains "student".
    If not, the file should contain several lines, one username per line.
    Return a list of students thus extracted."""
    with open(file, 'r') as f:
        if not file.endswith(".csv"):
            return f.read().splitlines()
        return [row[1] for row in csv.reader(f) if row[0] == "student"]