I've searched online about this problem and I've found two ways so far:
   while read line; do
      commands
   done < "$filename"
and
    for $line in $(cat $filename); do
       commands
    done
none of these work if the lines have a space though, for example if we have a line like that
  textextext text
it won't print textextext text
but
  textextext
  text
it counts these things as a different line, how can I avoid this to happen?