Narrative:

I was the captain and the PF iad to bos. We were cleared for takeoff by aid tower and instructed to maintain visibility sep with the aircraft that was launched just prior to us. His heading was 220 degrees assigned and we were assigned 240 degrees and to maintain 4000'. The takeoff runway was 19L. At about 2800' we were told to switch to departure. We first talked with departure control at about 3400' and checked in '3000 for 4000.' departure asked us to stop our climb at 3000'. We responded unable. I immediately initiated a level off and got level by 3600'. Within seconds we saw a third aircraft heading approximately north at 4000'. Approach asked us to turn north with no response about altitude. In my opinion, had we not leveled below 4000', we would have had a midair. The aircraft passed directly over the cockpit.

Google
 

Original NASA ASRS Text

Title: ACR CAME IN CLOSE PROX TO ANOTHER ACFT AFTER DEP.

Narrative: I WAS THE CAPT AND THE PF IAD TO BOS. WE WERE CLRED FOR TKOF BY AID TWR AND INSTRUCTED TO MAINTAIN VIS SEP WITH THE ACFT THAT WAS LAUNCHED JUST PRIOR TO US. HIS HDG WAS 220 DEGS ASSIGNED AND WE WERE ASSIGNED 240 DEGS AND TO MAINTAIN 4000'. THE TKOF RWY WAS 19L. AT ABOUT 2800' WE WERE TOLD TO SWITCH TO DEP. WE FIRST TALKED WITH DEP CTL AT ABOUT 3400' AND CHKED IN '3000 FOR 4000.' DEP ASKED US TO STOP OUR CLB AT 3000'. WE RESPONDED UNABLE. I IMMEDIATELY INITIATED A LEVEL OFF AND GOT LEVEL BY 3600'. WITHIN SECS WE SAW A THIRD ACFT HDG APPROX N AT 4000'. APCH ASKED US TO TURN N WITH NO RESPONSE ABOUT ALT. IN MY OPINION, HAD WE NOT LEVELED BELOW 4000', WE WOULD HAVE HAD A MIDAIR. THE ACFT PASSED DIRECTLY OVER THE COCKPIT.

Data retrieved from NASA's ASRS site as of August 2007 and automatically converted to unabbreviated mixed upper/lowercase text. This report is for informational purposes with no guarantee of accuracy. See NASA's ASRS site for official report.