View Problem

Process a file one line at a time

Open the source file to your solution and print each line in the file, prefixed by the line number, like:
1> First line of file
2> Second line of file
3> Third line of file
DiskEdit
ruby
File.open("Solution103.rb").each_with_index { |line, count|
puts "#{count} > #{line}
}
DiskEdit
csharp .Net 2.0 or later
int counter = 0;

// If the file is large, you would want to buffer this instead of reading everything at once
foreach (string line in System.IO.File.ReadAllLines("filename.txt"))
{
Console.WriteLine("{0}> {1}", ++counter, line);
}

Submit a new solution for ruby or csharp
There are 26 other solutions in additional languages (clojure, cpp, erlang, fantom ...)