Thibaut Barr?re wrote:
> Hi
>
> I'm practicing ruby everyday on small tools to learn more, could
> anyone review what I've coded today ? This is a basic line of code
> counter (pure ruby), any feedback welcome!
>
> thanks !
>
> Thibaut
>
> def loc_file(file)
>   File.open(file).inject(0) { |loc,line| loc+1 }
> end

You're not properly closing IO's.  Rather do

def loc_file(file)
  File.open(file) {|io| io.inject(0) { |loc,line| loc+1 } }
end

Kind regards

    robert