import gzip


def open_file_for_reading(filename):
    """Open the file gunzipping it if it ends with .gz."""
    if filename.lower().endswith(".gz"):
        return gzip.open(filename, "rb")
    else:
        return open(filename, "rb")