You can use f.read() to read the entire file's contents into a string, providing the file isn't huge. Then, split on "\r" and replace "\n" when found. A simple test: input_data = "abc\rdef\rghi\r\njkl\r\nmno\r\n" first_split = input_data.split("\r") for rec in first_split: rec = rec.replace("\n", "") print rec